Redocumented all device demos, now that they have changed over to the new USB class drivers.
Added C linkage to class drivers for C++ support.
Added prefixes to most of the class driver constants to prevent name clashes.
# List C source files here. (C dependencies are automatically generated.)\r
SRC = $(TARGET).c \\r
Descriptors.c \\r
- $(LUFA_PATH)/LUFA/Scheduler/Scheduler.c \\r
$(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/DevChapter9.c \\r
$(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Endpoint.c \\r
$(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Host.c \\r
# List C source files here. (C dependencies are automatically generated.)\r
SRC = $(TARGET).c \\r
Descriptors.c \\r
- $(LUFA_PATH)/LUFA/Scheduler/Scheduler.c \\r
$(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/DevChapter9.c \\r
$(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Endpoint.c \\r
$(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Host.c \\r
# List C source files here. (C dependencies are automatically generated.)\r
SRC = $(TARGET).c \\r
Descriptors.c \\r
- $(LUFA_PATH)/LUFA/Scheduler/Scheduler.c \\r
$(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/DevChapter9.c \\r
$(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Endpoint.c \\r
$(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Host.c \\r
this software.\r
*/\r
\r
+/** \file\r
+ *\r
+ * Main source file for the AudioInput demo. This file contains the main tasks of\r
+ * the demo and is responsible for the initial application hardware configuration.\r
+ */\r
+\r
#include "AudioInput.h"\r
\r
+/** LUFA Audio Class driver interface configuration and state information. This structure is\r
+ * passed to all Audio Class driver functions, so that multiple instances of the same class\r
+ * within a device can be differentiated from one another.\r
+ */\r
USB_ClassInfo_Audio_t Microphone_Audio_Interface =\r
{\r
- .InterfaceNumber = 0,\r
+ .StreamingInterfaceNumber = 1,\r
\r
- .DataINEndpointNumber = AUDIO_STREAM_EPNUM,\r
- .DataINEndpointSize = AUDIO_STREAM_EPSIZE,\r
+ .DataINEndpointNumber = AUDIO_STREAM_EPNUM,\r
+ .DataINEndpointSize = AUDIO_STREAM_EPSIZE,\r
};\r
- \r
+\r
+/** Main program entry point. This routine contains the overall program flow, including initial\r
+ * setup of all components and the main program loop.\r
+ */\r
int main(void)\r
{\r
SetupHardware();\r
}\r
}\r
\r
+/** Configures the board hardware and chip peripherals for the demo's functionality. */\r
void SetupHardware(void)\r
{\r
/* Disable watchdog if enabled by bootloader/fuses */\r
ADC_StartReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | MIC_IN_ADC_CHANNEL);\r
}\r
\r
+/** Processes the next audio sample by reading the last ADC conversion and writing it to the audio\r
+ * interface, each time the sample reload timer period elapses to give a constant sample rate.\r
+ */\r
void ProcessNextSample(void)\r
{\r
if ((TIFR0 & (1 << OCF0A)) && USB_Audio_IsReadyForNextSample(&Microphone_Audio_Interface))\r
}\r
}\r
\r
+/** Event handler for the library USB Connection event. */\r
void EVENT_USB_Connect(void)\r
{\r
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);\r
TCCR0B = (1 << CS00); // Fcpu speed\r
}\r
\r
+/** Event handler for the library USB Disconnection event. */\r
void EVENT_USB_Disconnect(void)\r
{\r
/* Stop the sample reload timer */\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_ERROR);\r
}\r
\r
+/** Event handler for the library USB Unhandled Control Packet event. */\r
void EVENT_USB_UnhandledControlPacket(void)\r
{\r
USB_Audio_ProcessControlPacket(&Microphone_Audio_Interface);\r
\r
/* Macros: */\r
/** ADC channel number for the microphone input. */\r
- #define MIC_IN_ADC_CHANNEL 2\r
+ #define MIC_IN_ADC_CHANNEL 2\r
\r
/** Maximum ADC sample value for the microphone input. */\r
- #define SAMPLE_MAX_RANGE 0xFFFF\r
+ #define SAMPLE_MAX_RANGE 0xFFFF\r
\r
/** Maximum ADC range for the microphone input. */\r
- #define ADC_MAX_RANGE 0x3FF\r
+ #define ADC_MAX_RANGE 0x3FF\r
\r
/* Macros: */\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */\r
#define LEDMASK_USB_NOTREADY LEDS_LED1\r
+\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */\r
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)\r
+\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is ready. */\r
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)\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
/* Function Prototypes: */\r
.BitResolution = 16,\r
.SampleFrequencyType = (sizeof(ConfigurationDescriptor.AudioFormat.SampleFrequencies) / sizeof(AudioSampleFreq_t)),\r
\r
- .SampleFrequencies = {SAMPLE_FREQ(AUDIO_SAMPLE_FREQUENCY)}\r
+ .SampleFrequencies = {AUDIO_SAMPLE_FREQ(AUDIO_SAMPLE_FREQUENCY)}\r
},\r
\r
.AudioEndpoint = \r
this software.\r
*/\r
\r
+/** \file\r
+ *\r
+ * Main source file for the AudioOutput demo. This file contains the main tasks of\r
+ * the demo and is responsible for the initial application hardware configuration.\r
+ */\r
+\r
#include "AudioOutput.h"\r
\r
+/** LUFA Audio Class driver interface configuration and state information. This structure is\r
+ * passed to all Audio Class driver functions, so that multiple instances of the same class\r
+ * within a device can be differentiated from one another.\r
+ */\r
USB_ClassInfo_Audio_t Speaker_Audio_Interface =\r
{\r
- .InterfaceNumber = 0,\r
+ .StreamingInterfaceNumber = 1,\r
\r
- .DataOUTEndpointNumber = AUDIO_STREAM_EPNUM,\r
- .DataOUTEndpointSize = AUDIO_STREAM_EPSIZE,\r
+ .DataOUTEndpointNumber = AUDIO_STREAM_EPNUM,\r
+ .DataOUTEndpointSize = AUDIO_STREAM_EPSIZE,\r
};\r
\r
+/** Main program entry point. This routine contains the overall program flow, including initial\r
+ * setup of all components and the main program loop.\r
+ */\r
int main(void)\r
{\r
SetupHardware();\r
}\r
}\r
\r
+/** Configures the board hardware and chip peripherals for the demo's functionality. */\r
void SetupHardware(void)\r
{\r
/* Disable watchdog if enabled by bootloader/fuses */\r
USB_Init();\r
}\r
\r
+/** Processes the next audio sample by reading the last ADC conversion and writing it to the audio\r
+ * interface, each time the sample reload timer period elapses to give a constant sample rate.\r
+ */\r
void ProcessNextSample(void)\r
{\r
if ((TIFR0 & (1 << OCF0A)) && USB_Audio_IsSampleReceived(&Speaker_Audio_Interface))\r
int8_t LeftSample_8Bit = (LeftSample_16Bit >> 8);\r
int8_t RightSample_8Bit = (RightSample_16Bit >> 8);\r
\r
-#if defined(AUDIO_OUT_MONO)\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)\r
/* Load the sample into the PWM timer channel */\r
OCRxA = ((uint8_t)MixedSample_8Bit ^ (1 << 7));\r
#elif defined(AUDIO_OUT_STEREO)\r
OCRxA = ((uint8_t)LeftSample_8Bit ^ (1 << 7));\r
OCRxB = ((uint8_t)RightSample_8Bit ^ (1 << 7));\r
#elif defined(AUDIO_OUT_PORTC)\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
PORTC = MixedSample_8Bit;\r
#else\r
uint8_t LEDMask = LEDS_NO_LEDS;\r
\r
- /* Make left channel positive (absolute) */\r
- if (LeftSample_8Bit < 0)\r
- LeftSample_8Bit = -LeftSample_8Bit;\r
-\r
- /* Make right channel positive (absolute) */\r
- if (RightSample_8Bit < 0)\r
- RightSample_8Bit = -RightSample_8Bit;\r
+ /* Make mixed sample value positive (absolute) */\r
+ if (MixedSample_8Bit < 0)\r
+ MixedSample_8Bit = -MixedSample_8Bit;\r
\r
- /* Set first LED based on sample value */\r
- if (LeftSample_8Bit < ((128 / 8) * 1))\r
- LEDMask |= LEDS_LED2;\r
- else if (LeftSample_8Bit < ((128 / 8) * 3))\r
- LEDMask |= (LEDS_LED1 | LEDS_LED2);\r
- else\r
+ if (MixedSample_8Bit > ((128 / 8) * 1))\r
LEDMask |= LEDS_LED1;\r
+ \r
+ if (MixedSample_8Bit > ((128 / 8) * 2))\r
+ LEDMask |= LEDS_LED2;\r
+ \r
+ if (MixedSample_8Bit > ((128 / 8) * 3))\r
+ LEDMask |= LEDS_LED3;\r
\r
- /* Set second LED based on sample value */\r
- if (RightSample_8Bit < ((128 / 8) * 1))\r
+ if (MixedSample_8Bit > ((128 / 8) * 4))\r
LEDMask |= LEDS_LED4;\r
- else if (RightSample_8Bit < ((128 / 8) * 3))\r
- LEDMask |= (LEDS_LED3 | LEDS_LED4);\r
- else\r
- LEDMask |= LEDS_LED3;\r
- \r
+\r
LEDs_SetAllLEDs(LEDMask);\r
#endif\r
}\r
}\r
\r
+/** Event handler for the library USB Connection event. */\r
void EVENT_USB_Connect(void)\r
{\r
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);\r
#endif \r
}\r
\r
-/** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via\r
- * the status LEDs, disables the sample update and PWM output timers and stops the USB and Audio management tasks.\r
- */\r
+/** Event handler for the library USB Disconnection event. */\r
void EVENT_USB_Disconnect(void)\r
{\r
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
\r
- /* Stop the timers */\r
+ /* Stop the sample reload timer */\r
TCCR0B = 0;\r
+\r
#if (defined(AUDIO_OUT_MONO) || defined(AUDIO_OUT_STEREO))\r
+ /* Stop the PWM generation timer */\r
TCCRxB = 0;\r
#endif \r
\r
#endif\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_ERROR);\r
}\r
\r
+/** Event handler for the library USB Unhandled Control Packet event. */\r
void EVENT_USB_UnhandledControlPacket(void)\r
{\r
USB_Audio_ProcessControlPacket(&Speaker_Audio_Interface);\r
#endif\r
\r
/* Macros: */\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */\r
#define LEDMASK_USB_NOTREADY LEDS_LED1\r
+\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */\r
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)\r
+\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is ready. */\r
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)\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
/* Function Prototypes: */\r
.BitResolution = 16,\r
\r
.SampleFrequencyType = (sizeof(ConfigurationDescriptor.AudioFormat.SampleFrequencies) / sizeof(AudioSampleFreq_t)), \r
- .SampleFrequencies = {SAMPLE_FREQ(AUDIO_SAMPLE_FREQUENCY)}\r
+ .SampleFrequencies = {AUDIO_SAMPLE_FREQ(AUDIO_SAMPLE_FREQUENCY)}\r
},\r
\r
.AudioEndpoint = \r
this software.\r
*/\r
\r
+/** \file\r
+ *\r
+ * Main source file for the CDC demo. This file contains the main tasks of\r
+ * the demo and is responsible for the initial application hardware configuration.\r
+ */\r
+ \r
#include "CDC.h"\r
\r
+/** LUFA CDC Class driver interface configuration and state information. This structure is\r
+ * passed to all CDC Class driver functions, so that multiple instances of the same class\r
+ * within a device can be differentiated from one another.\r
+ */\r
USB_ClassInfo_CDC_t VirtualSerial_CDC_Interface =\r
{\r
.ControlInterfaceNumber = 0,\r
.NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,\r
};\r
\r
+/** Main program entry point. This routine contains the overall program flow, including initial\r
+ * setup of all components and the main program loop.\r
+ */\r
int main(void)\r
{\r
SetupHardware();\r
}\r
}\r
\r
+/** Configures the board hardware and chip peripherals for the demo's functionality. */\r
void SetupHardware(void)\r
{\r
/* Disable watchdog if enabled by bootloader/fuses */\r
USB_Init();\r
}\r
\r
+/** Checks for changes in the position of the board joystick, sending strings to the host upon each change. */\r
void CheckJoystickMovement(void)\r
{\r
uint8_t JoyStatus_LCL = Joystick_GetStatus();\r
char* ReportString = NULL;\r
- static bool ActionSent = false;\r
+ static bool ActionSent = false;\r
\r
char* JoystickStrings[] =\r
{\r
}\r
}\r
\r
+/** Event handler for the library USB Connection event. */\r
void EVENT_USB_Connect(void)\r
{\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
}\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_ERROR);\r
}\r
\r
+/** Event handler for the library USB Unhandled Control Packet event. */\r
void EVENT_USB_UnhandledControlPacket(void)\r
{\r
USB_CDC_ProcessControlPacket(&VirtualSerial_CDC_Interface);\r
#include <LUFA/Drivers/USB/Class/Device/CDC.h>\r
\r
/* Macros: */\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */\r
#define LEDMASK_USB_NOTREADY LEDS_LED1\r
+\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */\r
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)\r
+\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is ready. */\r
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)\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
/* Function Prototypes: */\r
arising out of or in connection with the use or performance of\r
this software.\r
*/\r
- \r
+\r
+/** \file\r
+ *\r
+ * Main source file for the DualCDC demo. This file contains the main tasks of\r
+ * the demo and is responsible for the initial application hardware configuration.\r
+ */\r
+\r
#include "DualCDC.h"\r
\r
+/** LUFA CDC Class driver interface configuration and state information. This structure is\r
+ * passed to all CDC Class driver functions, so that multiple instances of the same class\r
+ * within a device can be differentiated from one another. This is for the first CDC interface,\r
+ * which sends strings to the host for each joystick movement.\r
+ */\r
USB_ClassInfo_CDC_t VirtualSerial1_CDC_Interface =\r
{\r
.ControlInterfaceNumber = 0,\r
.NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,\r
};\r
\r
+/** LUFA CDC Class driver interface configuration and state information. This structure is\r
+ * passed to all CDC Class driver functions, so that multiple instances of the same class\r
+ * within a device can be differentiated from one another. This is for the second CDC interface,\r
+ * which echos back all received data from the host.\r
+ */\r
USB_ClassInfo_CDC_t VirtualSerial2_CDC_Interface =\r
{\r
- .ControlInterfaceNumber = 0,\r
+ .ControlInterfaceNumber = 2,\r
\r
.DataINEndpointNumber = CDC2_TX_EPNUM,\r
.DataINEndpointSize = CDC_TXRX_EPSIZE,\r
.NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,\r
};\r
\r
+/** Main program entry point. This routine contains the overall program flow, including initial\r
+ * setup of all components and the main program loop.\r
+ */\r
int main(void)\r
{\r
SetupHardware();\r
{\r
CheckJoystickMovement();\r
\r
+ /* Discard all received data on the first CDC interface */\r
uint16_t BytesToDiscard = USB_CDC_BytesReceived(&VirtualSerial1_CDC_Interface);\r
while (BytesToDiscard--)\r
USB_CDC_ReceiveByte(&VirtualSerial1_CDC_Interface);\r
\r
+ /* Echo all received data on the second CDC interface */\r
uint16_t BytesToEcho = USB_CDC_BytesReceived(&VirtualSerial2_CDC_Interface);\r
while (BytesToEcho--)\r
USB_CDC_SendByte(&VirtualSerial2_CDC_Interface, USB_CDC_ReceiveByte(&VirtualSerial2_CDC_Interface));\r
}\r
}\r
\r
+/** Configures the board hardware and chip peripherals for the demo's functionality. */\r
void SetupHardware(void)\r
{\r
/* Disable watchdog if enabled by bootloader/fuses */\r
USB_Init();\r
}\r
\r
+/** Checks for changes in the position of the board joystick, sending strings to the host upon each change\r
+ * through the first of the CDC interfaces.\r
+ */\r
void CheckJoystickMovement(void)\r
{\r
uint8_t JoyStatus_LCL = Joystick_GetStatus();\r
}\r
}\r
\r
+/** Event handler for the library USB Connection event. */\r
void EVENT_USB_Connect(void)\r
{\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
}\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_ERROR);\r
}\r
\r
+/** Event handler for the library USB Unhandled Control Packet event. */\r
void EVENT_USB_UnhandledControlPacket(void)\r
{\r
USB_CDC_ProcessControlPacket(&VirtualSerial1_CDC_Interface);\r
#include <LUFA/Drivers/USB/Class/Device/CDC.h>\r
\r
/* Macros: */\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */\r
#define LEDMASK_USB_NOTREADY LEDS_LED1\r
+\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */\r
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)\r
+\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is ready. */\r
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)\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
/* Function Prototypes: */\r
this software.\r
*/\r
\r
+/** \file\r
+ *\r
+ * Main source file for the GenericHID demo. This file contains the main tasks of\r
+ * the demo and is responsible for the initial application hardware configuration.\r
+ */\r
+\r
#include "GenericHID.h"\r
\r
+/** LUFA HID Class driver interface configuration and state information. This structure is\r
+ * passed to all HID Class driver functions, so that multiple instances of the same class\r
+ * within a device can be differentiated from one another.\r
+ */\r
USB_ClassInfo_HID_t Generic_HID_Interface =\r
{\r
.InterfaceNumber = 0,\r
.UsingReportProtocol = true,\r
};\r
\r
+/** Main program entry point. This routine contains the overall program flow, including initial\r
+ * setup of all components and the main program loop.\r
+ */\r
int main(void)\r
{\r
SetupHardware();\r
}\r
}\r
\r
+/** Configures the board hardware and chip peripherals for the demo's functionality. */\r
void SetupHardware(void)\r
{\r
/* Disable watchdog if enabled by bootloader/fuses */\r
TIMSK0 = (1 << OCIE0A);\r
}\r
\r
+/** Event handler for the library USB Connection event. */\r
void EVENT_USB_Connect(void)\r
{\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
}\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_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(&Generic_HID_Interface);\r
}\r
\r
+/** ISR to keep track of each millisecond interrupt, for determining the HID class idle period remaining when set. */\r
ISR(TIMER0_COMPA_vect, ISR_BLOCK)\r
{\r
if (Generic_HID_Interface.IdleMSRemaining)\r
Generic_HID_Interface.IdleMSRemaining--;\r
}\r
\r
+/** HID class driver callback function for the creation of HID reports to the host.\r
+ *\r
+ * \param HIDInterfaceInfo Pointer to the HID class interface configuration structure being referenced\r
+ * \param ReportData Pointer to a buffer where the created report should be stored\r
+ *\r
+ * \return Number of bytes written in the report (or zero if no report is to be sent\r
+ */\r
uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData)\r
{\r
// Create generic HID report here\r
return 0;\r
}\r
\r
+/** HID class driver callback function for the processing of HID reports from the host.\r
+ *\r
+ * \param HIDInterfaceInfo Pointer to the HID class interface configuration structure being referenced\r
+ * \param ReportData Pointer to a buffer where the created report has been stored\r
+ * \param ReportSize Size in bytes of the received HID report\r
+ */\r
void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData, uint16_t ReportSize)\r
{\r
// Process received generic HID report here\r
#include <LUFA/Drivers/USB/Class/Device/HID.h>\r
\r
/* Macros: */\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */\r
#define LEDMASK_USB_NOTREADY LEDS_LED1\r
+\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */\r
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)\r
+\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is ready. */\r
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)\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
/* Function Prototypes: */\r
this software.\r
*/\r
\r
+/** \file\r
+ *\r
+ * Main source file for the Joystick demo. This file contains the main tasks of\r
+ * the demo and is responsible for the initial application hardware configuration.\r
+ */\r
+\r
#include "Joystick.h"\r
\r
+/** LUFA HID Class driver interface configuration and state information. This structure is\r
+ * passed to all HID Class driver functions, so that multiple instances of the same class\r
+ * within a device can be differentiated from one another.\r
+ */\r
USB_ClassInfo_HID_t Joystick_HID_Interface =\r
{\r
.InterfaceNumber = 0,\r
.UsingReportProtocol = true,\r
};\r
\r
+/** Main program entry point. This routine contains the overall program flow, including initial\r
+ * setup of all components and the main program loop.\r
+ */\r
int main(void)\r
{\r
SetupHardware();\r
}\r
}\r
\r
+/** Configures the board hardware and chip peripherals for the demo's functionality. */\r
void SetupHardware(void)\r
{\r
/* Disable watchdog if enabled by bootloader/fuses */\r
TIMSK0 = (1 << OCIE0A);\r
}\r
\r
+/** Event handler for the library USB Connection event. */\r
void EVENT_USB_Connect(void)\r
{\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
}\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_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(&Joystick_HID_Interface);\r
}\r
\r
+/** ISR to keep track of each millisecond interrupt, for determining the HID class idle period remaining when set. */\r
ISR(TIMER0_COMPA_vect, ISR_BLOCK)\r
{\r
if (Joystick_HID_Interface.IdleMSRemaining)\r
Joystick_HID_Interface.IdleMSRemaining--;\r
}\r
\r
+/** HID class driver callback function for the creation of HID reports to the host.\r
+ *\r
+ * \param HIDInterfaceInfo Pointer to the HID class interface configuration structure being referenced\r
+ * \param ReportData Pointer to a buffer where the created report should be stored\r
+ *\r
+ * \return Number of bytes written in the report (or zero if no report is to be sent\r
+ */\r
uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData)\r
{\r
USB_JoystickReport_Data_t* JoystickReport = (USB_JoystickReport_Data_t*)ReportData;\r
return sizeof(USB_JoystickReport_Data_t);\r
}\r
\r
+/** HID class driver callback function for the processing of HID reports from the host.\r
+ *\r
+ * \param HIDInterfaceInfo Pointer to the HID class interface configuration structure being referenced\r
+ * \param ReportData Pointer to a buffer where the created report has been stored\r
+ * \param ReportSize Size in bytes of the received HID report\r
+ */\r
void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData, uint16_t ReportSize)\r
{\r
// Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports\r
} USB_JoystickReport_Data_t;\r
\r
/* Macros: */\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */\r
#define LEDMASK_USB_NOTREADY LEDS_LED1\r
+\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */\r
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)\r
+\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is ready. */\r
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)\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
/* Function Prototypes: */\r
arising out of or in connection with the use or performance of\r
this software.\r
*/\r
- \r
+\r
+/** \file\r
+ *\r
+ * Main source file for the Keyboard demo. This file contains the main tasks of\r
+ * the demo and is responsible for the initial application hardware configuration.\r
+ */\r
+\r
#include "Keyboard.h"\r
\r
+/** LUFA HID Class driver interface configuration and state information. This structure is\r
+ * passed to all HID Class driver functions, so that multiple instances of the same class\r
+ * within a device can be differentiated from one another.\r
+ */\r
USB_ClassInfo_HID_t Keyboard_HID_Interface =\r
{\r
.InterfaceNumber = 0,\r
.IdleCount = 500,\r
};\r
\r
+/** Main program entry point. This routine contains the overall program flow, including initial\r
+ * setup of all components and the main program loop.\r
+ */\r
int main(void)\r
{\r
SetupHardware();\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
TIMSK0 = (1 << OCIE0A);\r
}\r
\r
+/** Event handler for the library USB Connection event. */\r
void EVENT_USB_Connect(void)\r
{\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
}\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_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
}\r
\r
+/** ISR to keep track of each millisecond interrupt, for determining the HID class idle period remaining when set. */\r
ISR(TIMER0_COMPA_vect, ISR_BLOCK)\r
{\r
if (Keyboard_HID_Interface.IdleMSRemaining)\r
Keyboard_HID_Interface.IdleMSRemaining--;\r
}\r
\r
+/** HID class driver callback function for the creation of HID reports to the host.\r
+ *\r
+ * \param HIDInterfaceInfo Pointer to the HID class interface configuration structure being referenced\r
+ * \param ReportData Pointer to a buffer where the created report should be stored\r
+ *\r
+ * \return Number of bytes written in the report (or zero if no report is to be sent\r
+ */\r
uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData)\r
{\r
USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData;\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
+ *\r
+ * \param HIDInterfaceInfo Pointer to the HID class interface configuration structure being referenced\r
+ * \param ReportData Pointer to a buffer where the created report has been stored\r
+ * \param ReportSize Size in bytes of the received HID report\r
+ */\r
void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData, uint16_t ReportSize)\r
{\r
uint8_t LEDMask = LEDS_NO_LEDS;\r
} USB_KeyboardReport_Data_t;\r
\r
/* Macros: */\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */\r
#define LEDMASK_USB_NOTREADY LEDS_LED1\r
+\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */\r
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)\r
+\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is ready. */\r
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)\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
/* Function Prototypes: */\r
arising out of or in connection with the use or performance of\r
this software.\r
*/\r
- \r
+\r
+/** \file\r
+ *\r
+ * Main source file for the KeyboardMouse demo. This file contains the main tasks of\r
+ * the demo and is responsible for the initial application hardware configuration.\r
+ */\r
+\r
#include "KeyboardMouse.h"\r
\r
+/** LUFA HID Class driver interface configuration and state information. This structure is\r
+ * passed to all HID Class driver functions, so that multiple instances of the same class\r
+ * within a device can be differentiated from one another. This is for the keyboard HID\r
+ * interface within the device.\r
+ */\r
USB_ClassInfo_HID_t Keyboard_HID_Interface =\r
{\r
.InterfaceNumber = 0,\r
.IdleCount = 500,\r
};\r
\r
+/** LUFA HID Class driver interface configuration and state information. This structure is\r
+ * passed to all HID Class driver functions, so that multiple instances of the same class\r
+ * within a device can be differentiated from one another. This is for the mouse HID\r
+ * interface within the device.\r
+ */\r
USB_ClassInfo_HID_t Mouse_HID_Interface =\r
{\r
.InterfaceNumber = 0,\r
.ReportOUTEndpointNumber = 0,\r
.ReportOUTEndpointSize = 0,\r
};\r
- \r
+\r
+/** Main program entry point. This routine contains the overall program flow, including initial\r
+ * setup of all components and the main program loop.\r
+ */\r
int main(void)\r
{\r
SetupHardware();\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
TIMSK0 = (1 << OCIE0A);\r
}\r
\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_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(&Mouse_HID_Interface);\r
}\r
\r
+/** ISR to keep track of each millisecond interrupt, for determining the HID class idle period remaining when set. */\r
ISR(TIMER0_COMPA_vect, ISR_BLOCK)\r
{\r
if (Keyboard_HID_Interface.IdleMSRemaining)\r
Mouse_HID_Interface.IdleMSRemaining--;\r
}\r
\r
+/** HID class driver callback function for the creation of HID reports to the host.\r
+ *\r
+ * \param HIDInterfaceInfo Pointer to the HID class interface configuration structure being referenced\r
+ * \param ReportData Pointer to a buffer where the created report should be stored\r
+ *\r
+ * \return Number of bytes written in the report (or zero if no report is to be sent\r
+ */\r
uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData)\r
{\r
uint8_t JoyStatus_LCL = Joystick_GetStatus();\r
}\r
}\r
\r
+/** HID class driver callback function for the processing of HID reports from the host.\r
+ *\r
+ * \param HIDInterfaceInfo Pointer to the HID class interface configuration structure being referenced\r
+ * \param ReportData Pointer to a buffer where the created report has been stored\r
+ * \param ReportSize Size in bytes of the received HID report\r
+ */\r
void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData, uint16_t ReportSize)\r
{\r
if (HIDInterfaceInfo == &Keyboard_HID_Interface)\r
#include <LUFA/Drivers/USB/Class/Device/HID.h>\r
\r
/* Macros: */\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */\r
#define LEDMASK_USB_NOTREADY LEDS_LED1\r
+\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */\r
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)\r
+\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is ready. */\r
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)\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
/* Type Defines: */\r
.Header = {.Size = sizeof(USB_MIDI_In_Jack_t), .Type = DTYPE_AudioInterface},\r
.Subtype = DSUBTYPE_InputJack,\r
\r
- .JackType = JACKTYPE_EMBEDDED,\r
+ .JackType = MIDI_JACKTYPE_EMBEDDED,\r
.JackID = 0x01,\r
\r
.JackStrIndex = NO_DESCRIPTOR\r
.Header = {.Size = sizeof(USB_MIDI_In_Jack_t), .Type = DTYPE_AudioInterface},\r
.Subtype = DSUBTYPE_InputJack,\r
\r
- .JackType = JACKTYPE_EXTERNAL,\r
+ .JackType = MIDI_JACKTYPE_EXTERNAL,\r
.JackID = 0x02,\r
\r
.JackStrIndex = NO_DESCRIPTOR\r
.Header = {.Size = sizeof(USB_MIDI_Out_Jack_t), .Type = DTYPE_AudioInterface},\r
.Subtype = DSUBTYPE_OutputJack,\r
\r
- .JackType = JACKTYPE_EMBEDDED,\r
+ .JackType = MIDI_JACKTYPE_EMBEDDED,\r
.JackID = 0x03,\r
\r
.NumberOfPins = 1,\r
.Header = {.Size = sizeof(USB_MIDI_Out_Jack_t), .Type = DTYPE_AudioInterface},\r
.Subtype = DSUBTYPE_OutputJack,\r
\r
- .JackType = JACKTYPE_EXTERNAL,\r
+ .JackType = MIDI_JACKTYPE_EXTERNAL,\r
.JackID = 0x04,\r
\r
.NumberOfPins = 1,\r
this software.\r
*/\r
\r
+/** \file\r
+ *\r
+ * Main source file for the MIDI demo. This file contains the main tasks of\r
+ * the demo and is responsible for the initial application hardware configuration.\r
+ */\r
+\r
#include "MIDI.h"\r
\r
+/** LUFA MIDI Class driver interface configuration and state information. This structure is\r
+ * passed to all MIDI Class driver functions, so that multiple instances of the same class\r
+ * within a device can be differentiated from one another.\r
+ */\r
USB_ClassInfo_MIDI_t Keyboard_MIDI_Interface =\r
{\r
- .InterfaceNumber = 0,\r
+ .StreamingInterfaceNumber = 1,\r
\r
- .DataINEndpointNumber = MIDI_STREAM_IN_EPNUM,\r
- .DataINEndpointSize = MIDI_STREAM_EPSIZE,\r
+ .DataINEndpointNumber = MIDI_STREAM_IN_EPNUM,\r
+ .DataINEndpointSize = MIDI_STREAM_EPSIZE,\r
\r
- .DataOUTEndpointNumber = MIDI_STREAM_OUT_EPNUM,\r
- .DataOUTEndpointSize = MIDI_STREAM_EPSIZE,\r
+ .DataOUTEndpointNumber = MIDI_STREAM_OUT_EPNUM,\r
+ .DataOUTEndpointSize = MIDI_STREAM_EPSIZE,\r
};\r
- \r
+\r
+/** Main program entry point. This routine contains the overall program flow, including initial\r
+ * setup of all components and the main program loop.\r
+ */\r
int main(void)\r
{\r
SetupHardware();\r
}\r
}\r
\r
+/** Configures the board hardware and chip peripherals for the demo's functionality. */\r
void SetupHardware(void)\r
{\r
/* Disable watchdog if enabled by bootloader/fuses */\r
USB_Init();\r
}\r
\r
+/** Checks for changes in the position of the board joystick, sending MIDI events to the host upon each change. */\r
void CheckJoystickMovement(void)\r
{\r
static uint8_t PrevJoystickStatus;\r
PrevJoystickStatus = JoystickStatus;\r
}\r
\r
+/** Event handler for the library USB Connection event. */\r
void EVENT_USB_Connect(void)\r
{\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
}\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
#include <LUFA/Drivers/USB/Class/Device/MIDI.h>\r
\r
/* Macros: */\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */\r
#define LEDMASK_USB_NOTREADY LEDS_LED1\r
+\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */\r
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)\r
+\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is ready. */\r
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)\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
/* Function Prototypes: */\r
this software.\r
*/\r
\r
+/** \file\r
+ *\r
+ * Main source file for the MassStorage demo. This file contains the main tasks of\r
+ * the demo and is responsible for the initial application hardware configuration.\r
+ */\r
+\r
#include "MassStorage.h"\r
\r
+/** LUFA Mass Storage Class driver interface configuration and state information. This structure is\r
+ * passed to all Mass Storage Class driver functions, so that multiple instances of the same class\r
+ * within a device can be differentiated from one another.\r
+ */\r
USB_ClassInfo_MS_t Disk_MS_Interface =\r
{\r
.InterfaceNumber = 0,\r
.TotalLUNs = TOTAL_LUNS,\r
};\r
\r
+/** Main program entry point. This routine contains the overall program flow, including initial\r
+ * setup of all components and the main program loop.\r
+ */\r
int main(void)\r
{\r
SetupHardware();\r
}\r
}\r
\r
+/** Configures the board hardware and chip peripherals for the demo's functionality. */\r
void SetupHardware(void)\r
{\r
/* Disable watchdog if enabled by bootloader/fuses */\r
DataflashManager_ResetDataflashProtections();\r
}\r
\r
+/** Event handler for the library USB Connection event. */\r
void EVENT_USB_Connect(void)\r
{\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
}\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_ERROR);\r
}\r
\r
+/** Event handler for the library USB Unhandled Control Packet event. */\r
void EVENT_USB_UnhandledControlPacket(void)\r
{\r
USB_MS_ProcessControlPacket(&Disk_MS_Interface);\r
}\r
\r
+/** Mass Storage class driver callback function the reception of SCSI commands from the host, which must be processed.\r
+ *\r
+ * \param MSInterfaceInfo Pointer to the Mass Storage class interface configuration structure being referenced\r
+ */\r
bool CALLBACK_USB_MS_SCSICommandReceived(USB_ClassInfo_MS_t* MSInterfaceInfo)\r
{\r
bool CommandSuccess;\r
#include <LUFA/Drivers/USB/Class/Device/MassStorage.h>
\r
/* Macros: */\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */\r
#define LEDMASK_USB_NOTREADY LEDS_LED1\r
+\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */\r
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)\r
+\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is ready. */\r
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)\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
- #define LEDMASK_USB_BUSY LEDS_LED2\r
+\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is busy. */\r
+ #define LEDMASK_USB_BUSY (LEDS_LED2)\r
\r
+ /** Total number of logical drives within the device - must be non-zero. */\r
#define TOTAL_LUNS 2\r
\r
/** Blocks in each LUN, calculated from the total capacity divided by the total number of Logical Units in the device. */\r
arising out of or in connection with the use or performance of\r
this software.\r
*/\r
- \r
+\r
+/** \file\r
+ *\r
+ * Main source file for the Mouse demo. This file contains the main tasks of\r
+ * the demo and is responsible for the initial application hardware configuration.\r
+ */\r
+\r
#include "Mouse.h"\r
\r
+/** LUFA HID Class driver interface configuration and state information. This structure is\r
+ * passed to all HID Class driver functions, so that multiple instances of the same class\r
+ * within a device can be differentiated from one another.\r
+ */\r
USB_ClassInfo_HID_t Mouse_HID_Interface =\r
{\r
.InterfaceNumber = 0,\r
.ReportINBufferSize = sizeof(USB_MouseReport_Data_t),\r
};\r
\r
+/** Main program entry point. This routine contains the overall program flow, including initial\r
+ * setup of all components and the main program loop.\r
+ */\r
int main(void)\r
{ \r
SetupHardware();\r
}\r
}\r
\r
+/** Configures the board hardware and chip peripherals for the demo's functionality. */\r
void SetupHardware(void)\r
{\r
/* Disable watchdog if enabled by bootloader/fuses */\r
TIMSK0 = (1 << OCIE0A);\r
}\r
\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_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(&Mouse_HID_Interface);\r
}\r
\r
+/** ISR to keep track of each millisecond interrupt, for determining the HID class idle period remaining when set. */\r
ISR(TIMER0_COMPA_vect, ISR_BLOCK)\r
{\r
if (Mouse_HID_Interface.IdleMSRemaining)\r
Mouse_HID_Interface.IdleMSRemaining--;\r
}\r
\r
+/** HID class driver callback function for the creation of HID reports to the host.\r
+ *\r
+ * \param HIDInterfaceInfo Pointer to the HID class interface configuration structure being referenced\r
+ * \param ReportData Pointer to a buffer where the created report should be stored\r
+ *\r
+ * \return Number of bytes written in the report (or zero if no report is to be sent\r
+ */\r
uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData)\r
{\r
USB_MouseReport_Data_t* MouseReport = (USB_MouseReport_Data_t*)ReportData;\r
return sizeof(USB_MouseReport_Data_t);\r
}\r
\r
+/** HID class driver callback function for the processing of HID reports from the host.\r
+ *\r
+ * \param HIDInterfaceInfo Pointer to the HID class interface configuration structure being referenced\r
+ * \param ReportData Pointer to a buffer where the created report has been stored\r
+ * \param ReportSize Size in bytes of the received HID report\r
+ */\r
void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData, uint16_t ReportSize)\r
{\r
// Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports\r
} USB_MouseReport_Data_t;\r
\r
/* Macros: */\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */\r
#define LEDMASK_USB_NOTREADY LEDS_LED1\r
+\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */\r
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)\r
+\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is ready. */\r
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)\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
/* Function Prototypes: */\r
this software.\r
*/\r
\r
+/** \file\r
+ *\r
+ * Main source file for the RNDISEthernet demo. This file contains the main tasks of\r
+ * the demo and is responsible for the initial application hardware configuration.\r
+ */\r
+\r
#include "RNDISEthernet.h"\r
\r
+/** LUFA RNDIS Class driver interface configuration and state information. This structure is\r
+ * passed to all RNDIS Class driver functions, so that multiple instances of the same class\r
+ * within a device can be differentiated from one another.\r
+ */\r
USB_ClassInfo_RNDIS_t Ethernet_RNDIS_Interface =\r
{\r
.ControlInterfaceNumber = 0,\r
.AdapterVendorDescription = "LUFA RNDIS Demo Adapter",\r
.AdapterMACAddress = {ADAPTER_MAC_ADDRESS},\r
};\r
- \r
+\r
+/** Main program entry point. This routine contains the overall program flow, including initial\r
+ * setup of all components and the main program loop.\r
+ */\r
int main(void)\r
{\r
SetupHardware();\r
\r
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
\r
+ TCP_Init();\r
+ Webserver_Init();\r
+\r
printf_P(PSTR("\r\n\r\n****** RNDIS Demo running. ******\r\n"));\r
\r
for (;;)\r
}\r
}\r
\r
+/** Configures the board hardware and chip peripherals for the demo's functionality. */\r
void SetupHardware(void)\r
{\r
/* Disable watchdog if enabled by bootloader/fuses */\r
LEDs_Init();\r
SerialStream_Init(9600, false);\r
USB_Init();\r
-\r
- /* Initialize TCP and Webserver modules */\r
- TCP_Init();\r
- Webserver_Init();\r
}\r
\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_ERROR);\r
}\r
\r
+/** Event handler for the library USB Unhandled Control Packet event. */\r
void EVENT_USB_UnhandledControlPacket(void)\r
{\r
USB_RNDIS_ProcessControlPacket(&Ethernet_RNDIS_Interface);\r
#include <LUFA/Drivers/USB/Class/Device/RNDIS.h>\r
\r
/* Macros: */\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */\r
#define LEDMASK_USB_NOTREADY LEDS_LED1\r
+\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */\r
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)\r
+\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is ready. */\r
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)\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
- #define LEDMASK_USB_BUSY LEDS_LED2\r
+\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is busy. */\r
+ #define LEDMASK_USB_BUSY (LEDS_LED2)\r
\r
/* Function Prototypes: */\r
void SetupHardware(void);\r
this software.\r
*/\r
\r
+/** \file\r
+ *\r
+ * Main source file for the USBtoSerial demo. This file contains the main tasks of\r
+ * the demo and is responsible for the initial application hardware configuration.\r
+ */\r
+\r
#include "USBtoSerial.h"\r
\r
+/** Circular buffer to hold data from the host before it is sent to the device via the serial port. */\r
RingBuff_t Rx_Buffer;\r
+\r
+/** Circular buffer to hold data from the serial port before it is sent to the host. */\r
RingBuff_t Tx_Buffer;\r
\r
+/** LUFA CDC Class driver interface configuration and state information. This structure is\r
+ * passed to all CDC Class driver functions, so that multiple instances of the same class\r
+ * within a device can be differentiated from one another.\r
+ */\r
USB_ClassInfo_CDC_t VirtualSerial_CDC_Interface =\r
{\r
.ControlInterfaceNumber = 0,\r
.NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,\r
};\r
\r
+/** Main program entry point. This routine contains the overall program flow, including initial\r
+ * setup of all components and the main program loop.\r
+ */\r
int main(void)\r
{\r
SetupHardware();\r
}\r
}\r
\r
+/** Configures the board hardware and chip peripherals for the demo's functionality. */\r
void SetupHardware(void)\r
{\r
/* Disable watchdog if enabled by bootloader/fuses */\r
USB_Init();\r
}\r
\r
+/** Event handler for the library USB Connection event. */\r
void EVENT_USB_Connect(void)\r
{\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
}\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_ERROR);\r
}\r
\r
+/** Event handler for the library USB Unhandled Control Packet event. */\r
void EVENT_USB_UnhandledControlPacket(void)\r
{\r
USB_CDC_ProcessControlPacket(&VirtualSerial_CDC_Interface);\r
}\r
\r
+/** ISR to manage the reception of data from the serial port, placing received bytes into a circular buffer\r
+ * for later transmission to the host.\r
+ */\r
ISR(USART1_RX_vect, ISR_BLOCK)\r
{\r
if (USB_IsConnected)\r
Buffer_StoreElement(&Tx_Buffer, UDR1);\r
}\r
\r
+/** Event handler for the CDC Class driver Line Encoding Changed event.\r
+ *\r
+ * \param CDCInterfaceInfo Pointer to the CDC class interface configuration structure being referenced\r
+ */\r
void EVENT_USB_CDC_LineEncodingChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo)\r
{\r
uint8_t ConfigMask = 0;\r
\r
- if (CDCInterfaceInfo->LineEncoding.ParityType == Parity_Odd)\r
+ if (CDCInterfaceInfo->LineEncoding.ParityType == CDC_PARITY_Odd)\r
ConfigMask = ((1 << UPM11) | (1 << UPM10));\r
- else if (CDCInterfaceInfo->LineEncoding.ParityType == Parity_Even)\r
+ else if (CDCInterfaceInfo->LineEncoding.ParityType == CDC_PARITY_Even)\r
ConfigMask = (1 << UPM11);\r
\r
- if (CDCInterfaceInfo->LineEncoding.CharFormat == TwoStopBits)\r
+ if (CDCInterfaceInfo->LineEncoding.CharFormat == CDC_LINEENCODING_TwoStopBits)\r
ConfigMask |= (1 << USBS1);\r
\r
if (CDCInterfaceInfo->LineEncoding.DataBits == 6)\r
#include <LUFA/Drivers/USB/Class/Device/CDC.h>\r
\r
/* Macros: */\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */\r
#define LEDMASK_USB_NOTREADY LEDS_LED1\r
+\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */\r
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)\r
+\r
+ /** LED mask for the library LED driver, to indicate that the USB interface is ready. */\r
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)\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
/* Function Prototypes: */\r
\r
========== TODO: ===========\r
- Document new class drivers\r
- - Re-document all demos now that they have changed\r
- Add standardized descriptor names to class driver structures, controlled by USE_NONSTANDARD_DESCRIPTOR_NAMES\r
- - Add C++ compatibility to class drivers\r
- Disable JTAG in demos\r
+ - Convert Host mode demos to class drivers\r
+ - Remake AVRStudio projects to reflect file structure changes\r
============================\r
\r
/** \page Page_ChangeLog Project Changelog\r
* this token is defined, all ANSI control codes in the application code from the TerminalCodes.h header are removed from\r
* the source code at compile time.\r
*\r
- * <b>NUM_BLOCKS</b> - ( \ref Group_MemoryAllocator ) \n\r
- * Sets the number of allocable blocks in the pseudo-heap of the dynamic memory allocation driver. This should be\r
- * defined as a constant larger than zero.\r
- *\r
- * <b>BLOCK_SIZE</b> - ( \ref Group_MemoryAllocator ) \n\r
- * Sets the size of each allocable block in the pseudo-heap of the dynamic memory allocation driver. This should be\r
- * defined as a constant larger than zero.\r
- *\r
- * <b>NUM_HANDLES</b> - ( \ref Group_MemoryAllocator ) \n\r
- * Sets the maximum number of managed memory handles which can be handed out by the dynamic memory allocation driver\r
- * simultaneously, before a handle (and its associated allocated memory) must be freed.\r
- *\r
- *\r
* \section Sec_SummaryUSBClassTokens USB Class Driver Related Tokens\r
* This section describes compile tokens which affect USB class-specific drivers in the LUFA library.\r
*\r
if (!(Endpoint_IsSETUPReceived()))\r
return;\r
\r
- if (USB_ControlRequest.wIndex != AudioInterfaceInfo->InterfaceNumber)\r
+ if (USB_ControlRequest.wIndex != AudioInterfaceInfo->StreamingInterfaceNumber)\r
return;\r
\r
switch (USB_ControlRequest.bRequest)\r
\r
#include <string.h>\r
\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
/* Macros: */\r
/** Descriptor header constant to indicate a Audio class interface descriptor. */\r
#define DTYPE_AudioInterface 0x24\r
*\r
* \param freq Required audio sampling frequency in HZ\r
*/\r
- #define SAMPLE_FREQ(freq) {LowWord: ((uint32_t)freq & 0x00FFFF), HighByte: (((uint32_t)freq >> 16) & 0x0000FF)}\r
+ #define AUDIO_SAMPLE_FREQ(freq) {LowWord: ((uint32_t)freq & 0x00FFFF), HighByte: (((uint32_t)freq >> 16) & 0x0000FF)}\r
\r
/** Mask for the attributes parameter of an Audio class specific Endpoint descriptor, indicating that the endpoint\r
* accepts only filled endpoint packets of audio samples.\r
\r
typedef struct\r
{\r
- uint8_t InterfaceNumber;\r
+ uint8_t StreamingInterfaceNumber;\r
\r
uint8_t DataINEndpointNumber;\r
uint16_t DataINEndpointSize;\r
void USB_Audio_WriteSample24(int32_t Sample);\r
bool USB_Audio_IsSampleReceived(USB_ClassInfo_Audio_t* AudioInterfaceInfo);\r
bool USB_Audio_IsReadyForNextSample(USB_ClassInfo_Audio_t* AudioInterfaceInfo);\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
#endif\r
\r
#include <string.h>\r
\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
/* Macros: */\r
/** CDC Class specific request to get the current virtual serial port configuration settings. */\r
- #define REQ_GetLineEncoding 0x21\r
+ #define REQ_GetLineEncoding 0x21\r
\r
/** CDC Class specific request to set the current virtual serial port configuration settings. */\r
- #define REQ_SetLineEncoding 0x20\r
+ #define REQ_SetLineEncoding 0x20\r
\r
/** CDC Class specific request to set the current virtual serial port handshake line states. */\r
- #define REQ_SetControlLineState 0x22\r
+ #define REQ_SetControlLineState 0x22\r
\r
/** Notification type constant for a change in the virtual serial port handshake line states, for\r
* use with a USB_Notification_Header_t notification structure when sent to the host via the CDC \r
* notification endpoint.\r
*/\r
- #define NOTIF_SerialState 0x20\r
+ #define NOTIF_SerialState 0x20\r
\r
/** Mask for the DTR handshake line for use with the REQ_SetControlLineState class specific request\r
* from the host, to indicate that the DTR line state should be high.\r
*/\r
- #define CONTROL_LINE_OUT_DTR (1 << 0)\r
+ #define CDC_CONTROL_LINE_OUT_DTR (1 << 0)\r
\r
/** Mask for the RTS handshake line for use with the REQ_SetControlLineState class specific request\r
* from the host, to indicate that theRTS line state should be high.\r
*/\r
- #define CONTROL_LINE_OUT_RTS (1 << 1)\r
+ #define CDC_CONTROL_LINE_OUT_RTS (1 << 1)\r
\r
/** Mask for the DCD handshake line for use with the a NOTIF_SerialState class specific notification\r
* from the device to the host, to indicate that the DCD line state is currently high.\r
*/\r
- #define CONTROL_LINE_IN_DCD (1 << 0)\r
+ #define CDC_CONTROL_LINE_IN_DCD (1 << 0)\r
\r
/** Mask for the DSR handshake line for use with the a NOTIF_SerialState class specific notification\r
* from the device to the host, to indicate that the DSR line state is currently high.\r
*/\r
- #define CONTROL_LINE_IN_DSR (1 << 1)\r
+ #define CDC_CONTROL_LINE_IN_DSR (1 << 1)\r
\r
/** Mask for the BREAK handshake line for use with the a NOTIF_SerialState class specific notification\r
* from the device to the host, to indicate that the BREAK line state is currently high.\r
*/\r
- #define CONTROL_LINE_IN_BREAK (1 << 2)\r
+ #define CDC_CONTROL_LINE_IN_BREAK (1 << 2)\r
\r
/** Mask for the RING handshake line for use with the a NOTIF_SerialState class specific notification\r
* from the device to the host, to indicate that the RING line state is currently high.\r
*/\r
- #define CONTROL_LINE_IN_RING (1 << 3)\r
+ #define CDC_CONTROL_LINE_IN_RING (1 << 3)\r
\r
/** Mask for use with the a NOTIF_SerialState class specific notification from the device to the host,\r
* to indicate that a framing error has occurred on the virtual serial port.\r
*/\r
- #define CONTROL_LINE_IN_FRAMEERROR (1 << 4)\r
+ #define CDC_CONTROL_LINE_IN_FRAMEERROR (1 << 4)\r
\r
/** Mask for use with the a NOTIF_SerialState class specific notification from the device to the host,\r
* to indicate that a parity error has occurred on the virtual serial port.\r
*/\r
- #define CONTROL_LINE_IN_PARITYERROR (1 << 5)\r
+ #define CDC_CONTROL_LINE_IN_PARITYERROR (1 << 5)\r
\r
/** Mask for use with the a NOTIF_SerialState class specific notification from the device to the host,\r
* to indicate that a data overrun error has occurred on the virtual serial port.\r
*/\r
- #define CONTROL_LINE_IN_OVERRUNERROR (1 << 6)\r
+ #define CDC_CONTROL_LINE_IN_OVERRUNERROR (1 << 6)\r
\r
/** Macro to define a CDC class-specific functional descriptor. CDC functional descriptors have a\r
* uniform structure but variable sized data payloads, thus cannot be represented accurately by\r
/** Enum for the possible line encoding formats of a virtual serial port. */\r
enum CDCDevice_CDC_LineCodingFormats_t\r
{\r
- OneStopBit = 0, /**< Each frame contains one stop bit */\r
- OneAndAHalfStopBits = 1, /**< Each frame contains one and a half stop bits */\r
- TwoStopBits = 2, /**< Each frame contains two stop bits */\r
+ CDC_LINEENCODING_OneStopBit = 0, /**< Each frame contains one stop bit */\r
+ CDC_LINEENCODING_OneAndAHalfStopBits = 1, /**< Each frame contains one and a half stop bits */\r
+ CDC_LINEENCODING_TwoStopBits = 2, /**< Each frame contains two stop bits */\r
};\r
\r
/** Enum for the possible line encoding parity settings of a virtual serial port. */\r
enum CDCDevice_LineCodingParity_t\r
{\r
- Parity_None = 0, /**< No parity bit mode on each frame */\r
- Parity_Odd = 1, /**< Odd parity bit mode on each frame */\r
- Parity_Even = 2, /**< Even parity bit mode on each frame */\r
- Parity_Mark = 3, /**< Mark parity bit mode on each frame */\r
- Parity_Space = 4, /**< Space parity bit mode on each frame */\r
+ CDC_PARITY_None = 0, /**< No parity bit mode on each frame */\r
+ CDC_PARITY_Odd = 1, /**< Odd parity bit mode on each frame */\r
+ CDC_PARITY_Even = 2, /**< Even parity bit mode on each frame */\r
+ CDC_PARITY_Mark = 3, /**< Mark parity bit mode on each frame */\r
+ CDC_PARITY_Space = 4, /**< Space parity bit mode on each frame */\r
};\r
\r
/* Type Defines: */\r
void EVENT_USB_CDC_ControLineStateChanged(void) ATTR_WEAK ATTR_ALIAS(USB_CDC_Event_Stub);; \r
#endif\r
\r
- void USB_CDC_USBTask(USB_ClassInfo_CDC_t* CDCInterfaceInfo);\r
bool USB_CDC_ConfigureEndpoints(USB_ClassInfo_CDC_t* CDCInterfaceInfo);\r
void USB_CDC_ProcessControlPacket(USB_ClassInfo_CDC_t* CDCInterfaceInfo);\r
void USB_CDC_USBTask(USB_ClassInfo_CDC_t* CDCInterfaceInfo);\r
uint16_t USB_CDC_BytesReceived(USB_ClassInfo_CDC_t* CDCInterfaceInfo);\r
uint8_t USB_CDC_ReceiveByte(USB_ClassInfo_CDC_t* CDCInterfaceInfo);\r
void USB_CDC_SendSerialLineStateChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo, uint16_t LineStateMask);\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
\r
#endif\r
\r
#include <string.h>\r
\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
/* Macros: */\r
/** HID Class Specific Request to get the current HID report from the device. */\r
#define REQ_GetReport 0x01\r
uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData);\r
void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData, uint16_t ReportSize);\r
\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
#endif\r
\r
#include <string.h>\r
\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
/* Macros: */\r
/** Audio class descriptor subtype value for a Audio class specific MIDI input jack descriptor. */\r
#define DSUBTYPE_InputJack 0x02\r
#define DSUBTYPE_OutputJack 0x03\r
\r
/** Audio class descriptor jack type value for an embedded (logical) MIDI input or output jack. */\r
- #define JACKTYPE_EMBEDDED 0x01\r
+ #define MIDI_JACKTYPE_EMBEDDED 0x01\r
\r
/** Audio class descriptor jack type value for an external (physical) MIDI input or output jack. */\r
- #define JACKTYPE_EXTERNAL 0x02\r
+ #define MIDI_JACKTYPE_EXTERNAL 0x02\r
\r
/** MIDI command for a note on (activation) event */\r
#define MIDI_COMMAND_NOTE_ON 0x09\r
\r
typedef struct\r
{\r
- uint8_t InterfaceNumber;\r
+ uint8_t StreamingInterfaceNumber;\r
\r
uint8_t DataINEndpointNumber;\r
uint16_t DataINEndpointSize;\r
void USB_MIDI_SendEventPacket(USB_ClassInfo_MIDI_t* MIDIInterfaceInfo, USB_MIDI_EventPacket_t* Event);\r
bool USB_MIDI_ReceiveEventPacket(USB_ClassInfo_MIDI_t* MIDIInterfaceInfo, USB_MIDI_EventPacket_t* Event);\r
\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
#endif\r
{\r
if (USB_MS_ReadInCommandBlock(MSInterfaceInfo))\r
{\r
- if (MSInterfaceInfo->CommandBlock.Flags & COMMAND_DIRECTION_DATA_IN)\r
+ if (MSInterfaceInfo->CommandBlock.Flags & MS_COMMAND_DIR_DATA_IN)\r
Endpoint_SelectEndpoint(MSInterfaceInfo->DataINEndpointNumber);\r
\r
MSInterfaceInfo->CommandStatus.Status = CALLBACK_USB_MS_SCSICommandReceived(MSInterfaceInfo) ?\r
- Command_Pass : Command_Fail;\r
- MSInterfaceInfo->CommandStatus.Signature = CSW_SIGNATURE;\r
+ SCSI_Command_Pass : SCSI_Command_Fail;\r
+ MSInterfaceInfo->CommandStatus.Signature = MS_CSW_SIGNATURE;\r
MSInterfaceInfo->CommandStatus.Tag = MSInterfaceInfo->CommandBlock.Tag;\r
MSInterfaceInfo->CommandStatus.DataTransferResidue = MSInterfaceInfo->CommandBlock.DataTransferLength;\r
\r
- if ((MSInterfaceInfo->CommandStatus.Status == Command_Fail) && (MSInterfaceInfo->CommandStatus.DataTransferResidue))\r
+ if ((MSInterfaceInfo->CommandStatus.Status == SCSI_Command_Fail) && (MSInterfaceInfo->CommandStatus.DataTransferResidue))\r
Endpoint_StallTransaction();\r
\r
USB_MS_ReturnCommandStatus(MSInterfaceInfo);\r
\r
CallbackMSInterfaceInfo = MSInterfaceInfo;\r
Endpoint_Read_Stream_LE(&MSInterfaceInfo->CommandBlock,\r
- (sizeof(CommandBlockWrapper_t) - MAX_SCSI_COMMAND_LENGTH),\r
+ (sizeof(CommandBlockWrapper_t) - 16),\r
StreamCallback_AbortOnMassStoreReset);\r
\r
- if ((MSInterfaceInfo->CommandBlock.Signature != CBW_SIGNATURE) ||\r
+ if ((MSInterfaceInfo->CommandBlock.Signature != MS_CBW_SIGNATURE) ||\r
(MSInterfaceInfo->CommandBlock.LUN >= MSInterfaceInfo->TotalLUNs) ||\r
- (MSInterfaceInfo->CommandBlock.SCSICommandLength > MAX_SCSI_COMMAND_LENGTH))\r
+ (MSInterfaceInfo->CommandBlock.SCSICommandLength > 16))\r
{\r
Endpoint_StallTransaction();\r
Endpoint_SelectEndpoint(MSInterfaceInfo->DataINEndpointNumber);\r
\r
#include <string.h>\r
\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
/* Macros: */\r
/** Mass Storage Class specific request to reset the Mass Storage interface, ready for the next command. */\r
#define REQ_MassStorageReset 0xFF\r
\r
/** Mass Storage Class specific request to retrieve the total number of Logical Units (drives) in the SCSI device. */\r
#define REQ_GetMaxLUN 0xFE\r
-\r
- /** Maximum length of a SCSI command which can be issued by the device or host in a Mass Storage bulk wrapper. */\r
- #define MAX_SCSI_COMMAND_LENGTH 16\r
\r
/** Magic signature for a Command Block Wrapper used in the Mass Storage Bulk-Only transport protocol. */\r
- #define CBW_SIGNATURE 0x43425355UL\r
+ #define MS_CBW_SIGNATURE 0x43425355UL\r
\r
/** Magic signature for a Command Status Wrapper used in the Mass Storage Bulk-Only transport protocol. */\r
- #define CSW_SIGNATURE 0x53425355UL\r
+ #define MS_CSW_SIGNATURE 0x53425355UL\r
\r
/** Mask for a Command Block Wrapper's flags attribute to specify a command with data sent from host-to-device. */\r
- #define COMMAND_DIRECTION_DATA_OUT (0 << 7)\r
+ #define MS_COMMAND_DIR_DATA_OUT (0 << 7)\r
\r
/** Mask for a Command Block Wrapper's flags attribute to specify a command with data sent from device-to-host. */\r
- #define COMMAND_DIRECTION_DATA_IN (1 << 7)\r
+ #define MS_COMMAND_DIR_DATA_IN (1 << 7)\r
\r
/* Type defines: */\r
/** Type define for a Command Block Wrapper, used in the Mass Storage Bulk-Only Transport protocol. */\r
uint8_t Flags; /**< Command block flags, indicating command data direction */\r
uint8_t LUN; /**< Logical Unit number this command is issued to */\r
uint8_t SCSICommandLength; /**< Length of the issued SCSI command within the SCSI command data array */\r
- uint8_t SCSICommandData[MAX_SCSI_COMMAND_LENGTH]; /**< Issued SCSI command in the Command Block */\r
+ uint8_t SCSICommandData[16]; /**< Issued SCSI command in the Command Block */\r
} CommandBlockWrapper_t;\r
\r
/** Type define for a Command Status Wrapper, used in the Mass Storage Bulk-Only Transport protocol. */\r
/** Enum for the possible command status wrapper return status codes. */\r
enum MassStorage_CommandStatusCodes_t\r
{\r
- Command_Pass = 0, /**< Command completed with no error */\r
- Command_Fail = 1, /**< Command failed to complete - host may check the exact error via a SCSI REQUEST SENSE command */\r
- Phase_Error = 2 /**< Command failed due to being invalid in the current phase */\r
+ SCSI_Command_Pass = 0, /**< Command completed with no error */\r
+ SCSI_Command_Fail = 1, /**< Command failed to complete - host may check the exact error via a SCSI REQUEST SENSE command */\r
+ SCSI_Phase_Error = 2 /**< Command failed due to being invalid in the current phase */\r
};\r
\r
/* Type Defines: */\r
static uint8_t StreamCallback_AbortOnMassStoreReset(void);\r
#endif\r
\r
- void USB_MS_USBTask(USB_ClassInfo_MS_t* MSInterfaceInfo);\r
bool USB_MS_ConfigureEndpoints(USB_ClassInfo_MS_t* MSInterfaceInfo);\r
void USB_MS_ProcessControlPacket(USB_ClassInfo_MS_t* MSInterfaceInfo);\r
+ void USB_MS_USBTask(USB_ClassInfo_MS_t* MSInterfaceInfo);\r
\r
bool CALLBACK_USB_MS_SCSICommandReceived(USB_ClassInfo_MS_t* MSInterfaceInfo);\r
\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
#endif\r
#include "../../USB.h"\r
#include "RNDISConstants.h"\r
\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
/* Macros: */\r
/** Implemented RNDIS Version Major */\r
#define REMOTE_NDIS_VERSION_MAJOR 0x01\r
void* SetData, uint16_t SetSize); \r
#endif\r
\r
- void USB_RNDIS_USBTask(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo);\r
bool USB_RNDIS_ConfigureEndpoints(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo);\r
void USB_RNDIS_ProcessControlPacket(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo);\r
+ void USB_RNDIS_USBTask(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo);\r
+ \r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
\r
#endif\r
* \note This event does not exist if the USB_DEVICE_ONLY token is supplied to the compiler (see\r
* \ref Group_USBManagement documentation).\r
*\r
- * \see \ref TASK(USB_USBTask) for more information on the USB management task and reducing CPU usage.\r
+ * \see \ref USB_USBTask() for more information on the USB management task and reducing CPU usage.\r
*/\r
void EVENT_USB_DeviceAttached(void);\r
\r
* \note This event does not exist if the USB_DEVICE_ONLY token is supplied to the compiler (see\r
* \ref Group_USBManagement documentation).\r
*\r
- * \see \ref TASK(USB_USBTask) for more information on the USB management task and reducing CPU usage.\r
+ * \see \ref USB_USBTask() for more information on the USB management task and reducing CPU usage.\r
*/\r
void EVENT_USB_DeviceUnattached(void);\r
\r
* - AT90USB1287 (USB Host and Device)\r
* - AT90USB646 (USB Device Only)\r
* - AT90USB647 (USB Host and Device)\r
- * - AT90USB162 (USB Device Only)\r
* - AT90USB82 (USB Device Only)\r
+ * - AT90USB162 (USB Device Only)\r
* - ATMEGA16U4 (USB Device Only)\r
- * - ATMEGA32U6 (USB Device Only)\r
* - ATMEGA32U4 (USB Device Only)\r
+ * - ATMEGA32U6 (USB Device Only)\r
*\r
* Currently supported Atmel boards:\r
* - AT90USBKEY\r
*\r
*\r
* \section Sec_Donations Donate\r
- * I am a 20 year old University student studying for a double degree in Computer Science and Electronics\r
- * Engineering. This leaves little time for any sort of work or leisure. Please consider donating a small amount\r
- * to myself to support this and my future Open Source projects. You can donate any amount via PayPal on my\r
- * website, http://www.fourwalledcubicle.com . All donations are greatly appreciated.\r
+ * I am a 20 year old University student studying for a double degree in Computer Science and Electronics Engineering.\r
+ * The development and support of this library requires much effort from myself. Please consider donating a small amount\r
+ * to myself to support this and my future Open Source projects. You can donate any amount via PayPal on my website, \r
+ * http://www.fourwalledcubicle.com . All donations are greatly appreciated.\r
*/\r
\r
* - Support for non-control data endpoint interrupts has been dropped due to many issues in the implementation. All existing\r
* projects using interrupts on non-control endpoints should switch to polling. For control interrupts, the library can\r
* manage the control endpoint via interrupts automatically by compiling with the INTERRUPT_CONTROL_ENDPOINT token defined.\r
- * - The Endpoint_ClearEndpointInterrupt() macro has been deleted and references to it should be removed.\r
* - The DESCRIPTOR_ADDRESS() macro has been removed. User applications should use normal casts to obtain a descriptor's memory\r
* address.\r
* - The library events system has been rewritten, so that all macros have been removed to allow for clearer user code. See\r
* <b>Host Mode</b>\r
* - Support for non-control data pipe interrupts has been dropped due to many issues in the implementation. All existing\r
* projects using interrupts on non-control pipes should switch to polling.\r
- * - The Pipe_ClearPipeInterrupt() macro has been deleted and references to it should be removed.\r
* - The library events system has been rewritten, so that all macros have been removed to allow for clearer user code. See\r
* \ref Group_Events for new API details.\r
* - The STREAM_CALLBACK() macro has been removed. User applications should replace all instances of the macro with regular\r
* function signatures of a function accepting no arguments and returning a uint8_t value.\r
* - The DESCRIPTOR_COMPARATOR() macro has been removed. User applications should replace all instances of the macro with\r
- * regular function signatures of a function accepting a pointer to the descriptor to test, and returning a uint8_t value.\r
+ * regular function signatures of a function accepting a void pointer to the descriptor to test, and returning a uint8_t value.\r
*\r
*\r
* \section Sec_Migration090510 Migrating from 090401 to 090510\r
* 0x2041\r
* </td>\r
* <td>\r
- * Mouse Demo Application (and derivatives)\r
+ * Mouse Demo Application\r
* </td>\r
* </tr>\r
*\r
* 0x2042\r
* </td>\r
* <td>\r
- * Keyboard Demo Application (and derivatives)\r
+ * Keyboard Demo Application\r
* </td>\r
* </tr>\r
*\r
this software.\r
*/\r
\r
+/** \file\r
+ *\r
+ * Main source file for the MagStripe reader program. This file contains the main tasks of\r
+ * the project and is responsible for the initial application hardware configuration.\r
+ */\r
+ \r
#include "Magstripe.h"\r
\r
+/** Bit buffers to hold the read bits for each of the three magnetic card tracks before they are transmitted\r
+ * to the host as keyboard presses.\r
+ */\r
BitBuffer_t TrackDataBuffers[3];\r
\r
+/** LUFA HID Class driver interface configuration and state information. This structure is\r
+ * passed to all HID Class driver functions, so that multiple instances of the same class\r
+ * within a device can be differentiated from one another.\r
+ */\r
USB_ClassInfo_HID_t Keyboard_HID_Interface =\r
{\r
.InterfaceNumber = 0,\r
.ReportINBufferSize = sizeof(USB_KeyboardReport_Data_t),\r
};\r
\r
+/** Main program entry point. This routine contains the overall program flow, including initial\r
+ * setup of all components and the main program loop.\r
+ */\r
int main(void)\r
{\r
SetupHardware();\r
}\r
}\r
\r
+/** Configures the board hardware and chip peripherals for the demo's functionality. */\r
void SetupHardware(void)\r
{\r
/* Disable watchdog if enabled by bootloader/fuses */\r
TIMSK0 = (1 << OCIE0A);\r
}\r
\r
+/** Determines if a card has been inserted, and if so reads in each track's contents into the bit buffers\r
+ * until they are read out to the host as a series of keyboard presses.\r
+ */\r
void ReadMagstripeData(void)\r
{\r
/* Arrays to hold the buffer pointers, clock and data bit masks for the separate card tracks */\r
}\r
}\r
\r
+/** Event handler for the library USB Configuration Changed event. */\r
void EVENT_USB_ConfigurationChanged(void)\r
{\r
USB_HID_ConfigureEndpoints(&Keyboard_HID_Interface);\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
}\r
\r
+/** Timer 0 CTC ISR, firing once each millisecond to keep track of elapsed idle time in the HID interface. */\r
ISR(TIMER0_COMPA_vect, ISR_BLOCK)\r
{\r
if (Keyboard_HID_Interface.IdleMSRemaining)\r
Keyboard_HID_Interface.IdleMSRemaining--;\r
}\r
\r
+/** HID Class driver callback function for the creation of a HID report for the host.\r
+ *\r
+ * \param HIDInterfaceInfo Pointer to the HID interface structure for the HID interface being referenced\r
+ * \param ReportData Pointer to the preallocated report buffer where the created report should be stored\r
+ *\r
+ * \return Number of bytes in the created report\r
+ */\r
uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData)\r
{\r
static bool IsKeyReleaseReport;\r
return sizeof(USB_KeyboardReport_Data_t);\r
}\r
\r
+/** HID Class driver callback function for the processing of a received HID report from the host.\r
+ *\r
+ * \param HIDInterfaceInfo Pointer to the HID interface structure for the HID interface being referenced\r
+ * \param ReportData Pointer to the report buffer where the received report is stored\r
+ * \param ReportSize Size in bytes of the report received from the host\r
+ */\r
void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData, uint16_t ReportSize)\r
{\r
// Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports\r