From cf22a744ec0da3b68c4ffdb14c6fa43f2e07542f Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Mon, 7 Dec 2009 04:35:59 +0000 Subject: Additional file renames and modifications to change CDC demos to VirtualSerial. --- .../ClassDriver/VirtualSerialMouse/CDCMouse.c | 240 --------------------- .../ClassDriver/VirtualSerialMouse/CDCMouse.h | 82 ------- .../ClassDriver/VirtualSerialMouse/CDCMouse.txt | 75 ------- .../ClassDriver/VirtualSerialMouse/Doxygen.conf | 2 +- .../VirtualSerialMouse/LUFA CDCMouse.inf | 106 --------- .../VirtualSerialMouse/LUFA VirtualSerialMouse.inf | 106 +++++++++ .../VirtualSerialMouse/VirtualSerialMouse.c | 240 +++++++++++++++++++++ .../VirtualSerialMouse/VirtualSerialMouse.h | 82 +++++++ .../VirtualSerialMouse/VirtualSerialMouse.txt | 75 +++++++ .../Device/ClassDriver/VirtualSerialMouse/makefile | 2 +- 10 files changed, 505 insertions(+), 505 deletions(-) delete mode 100644 Demos/Device/ClassDriver/VirtualSerialMouse/CDCMouse.c delete mode 100644 Demos/Device/ClassDriver/VirtualSerialMouse/CDCMouse.h delete mode 100644 Demos/Device/ClassDriver/VirtualSerialMouse/CDCMouse.txt delete mode 100644 Demos/Device/ClassDriver/VirtualSerialMouse/LUFA CDCMouse.inf create mode 100644 Demos/Device/ClassDriver/VirtualSerialMouse/LUFA VirtualSerialMouse.inf create mode 100644 Demos/Device/ClassDriver/VirtualSerialMouse/VirtualSerialMouse.c create mode 100644 Demos/Device/ClassDriver/VirtualSerialMouse/VirtualSerialMouse.h create mode 100644 Demos/Device/ClassDriver/VirtualSerialMouse/VirtualSerialMouse.txt (limited to 'Demos/Device/ClassDriver/VirtualSerialMouse') diff --git a/Demos/Device/ClassDriver/VirtualSerialMouse/CDCMouse.c b/Demos/Device/ClassDriver/VirtualSerialMouse/CDCMouse.c deleted file mode 100644 index d979e665c..000000000 --- a/Demos/Device/ClassDriver/VirtualSerialMouse/CDCMouse.c +++ /dev/null @@ -1,240 +0,0 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2009. - - dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com -*/ - -/* - Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, and distribute this software - and its documentation for any purpose and without fee is hereby - granted, provided that the above copyright notice appear in all - copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * - * Main source file for the CDCMouse demo. This file contains the main tasks of - * the demo and is responsible for the initial application hardware configuration. - */ - -#include "CDCMouse.h" - -/** LUFA CDC Class driver interface configuration and state information. This structure is - * passed to all CDC Class driver functions, so that multiple instances of the same class - * within a device can be differentiated from one another. - */ -USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface = - { - .Config = - { - .ControlInterfaceNumber = 0, - - .DataINEndpointNumber = CDC_TX_EPNUM, - .DataINEndpointSize = CDC_TXRX_EPSIZE, - .DataINEndpointDoubleBank = false, - - .DataOUTEndpointNumber = CDC_RX_EPNUM, - .DataOUTEndpointSize = CDC_TXRX_EPSIZE, - .DataOUTEndpointDoubleBank = false, - - .NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM, - .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE, - .NotificationEndpointDoubleBank = false, - }, - }; - -/** Buffer to hold the previously generated Mouse HID report, for comparison purposes inside the HID class driver. */ -uint8_t PrevMouseHIDReportBuffer[sizeof(USB_MouseReport_Data_t)]; - -/** LUFA HID Class driver interface configuration and state information. This structure is - * passed to all HID Class driver functions, so that multiple instances of the same class - * within a device can be differentiated from one another. - */ -USB_ClassInfo_HID_Device_t Mouse_HID_Interface = - { - .Config = - { - .InterfaceNumber = 0, - - .ReportINEndpointNumber = MOUSE_EPNUM, - .ReportINEndpointSize = MOUSE_EPSIZE, - .ReportINEndpointDoubleBank = false, - - .PrevReportINBuffer = PrevMouseHIDReportBuffer, - .PrevReportINBufferSize = sizeof(PrevMouseHIDReportBuffer), - }, - }; - -/** Main program entry point. This routine contains the overall program flow, including initial - * setup of all components and the main program loop. - */ -int main(void) -{ - SetupHardware(); - - LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); - - for (;;) - { - CheckJoystickMovement(); - - /* Must throw away unused bytes from the host, or it will lock up while waiting for the device */ - while (CDC_Device_BytesReceived(&VirtualSerial_CDC_Interface)) - CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface); - - CDC_Device_USBTask(&VirtualSerial_CDC_Interface); - HID_Device_USBTask(&Mouse_HID_Interface); - USB_USBTask(); - } -} - -/** Configures the board hardware and chip peripherals for the demo's functionality. */ -void SetupHardware(void) -{ - /* Disable watchdog if enabled by bootloader/fuses */ - MCUSR &= ~(1 << WDRF); - wdt_disable(); - - /* Disable clock division */ - clock_prescale_set(clock_div_1); - - /* Hardware Initialization */ - Joystick_Init(); - LEDs_Init(); - USB_Init(); -} - -/** Checks for changes in the position of the board joystick, sending strings to the host upon each change. */ -void CheckJoystickMovement(void) -{ - uint8_t JoyStatus_LCL = Joystick_GetStatus(); - char* ReportString = NULL; - static bool ActionSent = false; - - if (JoyStatus_LCL & JOY_UP) - ReportString = "Joystick Up\r\n"; - else if (JoyStatus_LCL & JOY_DOWN) - ReportString = "Joystick Down\r\n"; - else if (JoyStatus_LCL & JOY_LEFT) - ReportString = "Joystick Left\r\n"; - else if (JoyStatus_LCL & JOY_RIGHT) - ReportString = "Joystick Right\r\n"; - else if (JoyStatus_LCL & JOY_PRESS) - ReportString = "Joystick Pressed\r\n"; - else - ActionSent = false; - - if ((ReportString != NULL) && (ActionSent == false)) - { - ActionSent = true; - - CDC_Device_SendString(&VirtualSerial_CDC_Interface, ReportString, strlen(ReportString)); - } -} - -/** Event handler for the library USB Connection event. */ -void EVENT_USB_Device_Connect(void) -{ - LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); -} - -/** Event handler for the library USB Disconnection event. */ -void EVENT_USB_Device_Disconnect(void) -{ - LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); -} - -/** Event handler for the library USB Configuration Changed event. */ -void EVENT_USB_Device_ConfigurationChanged(void) -{ - LEDs_SetAllLEDs(LEDMASK_USB_READY); - - if (!(CDC_Device_ConfigureEndpoints(&VirtualSerial_CDC_Interface))) - LEDs_SetAllLEDs(LEDMASK_USB_ERROR); - - if (!(HID_Device_ConfigureEndpoints(&Mouse_HID_Interface))) - LEDs_SetAllLEDs(LEDMASK_USB_ERROR); - - USB_Device_EnableSOFEvents(); -} - -/** Event handler for the library USB Unhandled Control Request event. */ -void EVENT_USB_Device_UnhandledControlRequest(void) -{ - CDC_Device_ProcessControlRequest(&VirtualSerial_CDC_Interface); - HID_Device_ProcessControlRequest(&Mouse_HID_Interface); -} - -/** Event handler for the USB device Start Of Frame event. */ -void EVENT_USB_Device_StartOfFrame(void) -{ - HID_Device_MillisecondElapsed(&Mouse_HID_Interface); -} - -/** HID class driver callback function for the creation of HID reports to the host. - * - * \param[in] HIDInterfaceInfo Pointer to the HID class interface configuration structure being referenced - * \param[in,out] ReportID Report ID requested by the host if non-zero, otherwise callback should set to the generated report ID - * \param[in] ReportType Type of the report to create, either REPORT_ITEM_TYPE_In or REPORT_ITEM_TYPE_Feature - * \param[out] ReportData Pointer to a buffer where the created report should be stored - * \param[out] ReportSize Number of bytes written in the report (or zero if no report is to be sent - * - * \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent - */ -bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID, - const uint8_t ReportType, void* ReportData, uint16_t* ReportSize) -{ - USB_MouseReport_Data_t* MouseReport = (USB_MouseReport_Data_t*)ReportData; - - uint8_t JoyStatus_LCL = Joystick_GetStatus(); - uint8_t ButtonStatus_LCL = Buttons_GetStatus(); - - if (JoyStatus_LCL & JOY_UP) - MouseReport->Y = -1; - else if (JoyStatus_LCL & JOY_DOWN) - MouseReport->Y = 1; - - if (JoyStatus_LCL & JOY_LEFT) - MouseReport->X = -1; - else if (JoyStatus_LCL & JOY_RIGHT) - MouseReport->X = 1; - - if (JoyStatus_LCL & JOY_PRESS) - MouseReport->Button = (1 << 0); - - if (ButtonStatus_LCL & BUTTONS_BUTTON1) - MouseReport->Button |= (1 << 1); - - *ReportSize = sizeof(USB_MouseReport_Data_t); - return true; -} - -/** HID class driver callback function for the processing of HID reports from the host. - * - * \param[in] HIDInterfaceInfo Pointer to the HID class interface configuration structure being referenced - * \param[in] ReportID Report ID of the received report from the host - * \param[in] ReportData Pointer to a buffer where the created report has been stored - * \param[in] ReportSize Size in bytes of the received HID report - */ -void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, const uint8_t ReportID, - const void* ReportData, const uint16_t ReportSize) -{ - // Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports -} diff --git a/Demos/Device/ClassDriver/VirtualSerialMouse/CDCMouse.h b/Demos/Device/ClassDriver/VirtualSerialMouse/CDCMouse.h deleted file mode 100644 index bee1b0435..000000000 --- a/Demos/Device/ClassDriver/VirtualSerialMouse/CDCMouse.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2009. - - dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com -*/ - -/* - Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, and distribute this software - and its documentation for any purpose and without fee is hereby - granted, provided that the above copyright notice appear in all - copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * - * Header file for CDCMouse.c. - */ - -#ifndef _CDC_MOUSE_H_ -#define _CDC_MOUSE_H_ - - /* Includes: */ - #include - #include - #include - #include - - #include "Descriptors.h" - - #include - #include - #include - #include - #include - #include - #include - - /* Macros: */ - /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ - #define LEDMASK_USB_NOTREADY LEDS_LED1 - - /** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */ - #define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3) - - /** LED mask for the library LED driver, to indicate that the USB interface is ready. */ - #define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4) - - /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ - #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) - - /* Function Prototypes: */ - void SetupHardware(void); - void CheckJoystickMovement(void); - - void EVENT_USB_Device_Connect(void); - void EVENT_USB_Device_Disconnect(void); - void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_UnhandledControlRequest(void); - void EVENT_USB_Device_StartOfFrame(void); - - bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID, - const uint8_t ReportType, void* ReportData, uint16_t* ReportSize); - void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, const uint8_t ReportID, - const void* ReportData, const uint16_t ReportSize); -#endif diff --git a/Demos/Device/ClassDriver/VirtualSerialMouse/CDCMouse.txt b/Demos/Device/ClassDriver/VirtualSerialMouse/CDCMouse.txt deleted file mode 100644 index ff0d8a361..000000000 --- a/Demos/Device/ClassDriver/VirtualSerialMouse/CDCMouse.txt +++ /dev/null @@ -1,75 +0,0 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - -/** \mainpage Combined Communications Device Class (Virtual Serial Port) and Mouse Demo - * - * \section SSec_Compat Demo Compatibility: - * - * The following list indicates what microcontrollers are compatible with this demo. - * - * - Series 7 USB AVRs - * - Series 6 USB AVRs - * - Series 4 USB AVRs - * - Series 2 USB AVRs - * - * \section SSec_Info USB Information: - * - * The following table gives a rundown of the USB utilization of this demo. - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
USB Mode:Device
USB Class:Communications Device Class (CDC)Human Interface Device Class (HID)
USB Subclass:Abstract Control Model (ACM)Mouse Subclass
Relevant Standards:USBIF CDC Class StandardUSBIF HID Specification, USBIF HID Usage Tables
Usable Speeds:Full Speed Mode
- * - * \section SSec_Description Project Description: - * - * Combined Communications Device Class/Mouse demonstration application. - * This gives a simple reference application for implementing a combined - * CDC and HID device acting as a both a virtual serial port and a mouse. - * Joystick actions are transmitted to the host as strings and as mouse - * movements. The device does not respond to serial data sent from the host. - * - * After running this demo for the first time on a new computer, - * you will need to supply the .INF file located in this demo - * project's directory as the device's driver when running under - * Windows. This will enable Windows to use its inbuilt CDC drivers, - * negating the need for custom drivers for the device. Other - * Operating Systems should automatically use their own inbuilt - * CDC-ACM drivers. - * - * \section SSec_Options Project Options - * - * The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. - * - * - * - * - * - *
- * None - *
- */ \ No newline at end of file diff --git a/Demos/Device/ClassDriver/VirtualSerialMouse/Doxygen.conf b/Demos/Device/ClassDriver/VirtualSerialMouse/Doxygen.conf index 38e30f5f7..30849907a 100644 --- a/Demos/Device/ClassDriver/VirtualSerialMouse/Doxygen.conf +++ b/Demos/Device/ClassDriver/VirtualSerialMouse/Doxygen.conf @@ -25,7 +25,7 @@ DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. -PROJECT_NAME = "LUFA Library - Combined CDC and Mouse Device Demo" +PROJECT_NAME = "LUFA Library - Combined Virtual Serial and Mouse Device Demo" # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or diff --git a/Demos/Device/ClassDriver/VirtualSerialMouse/LUFA CDCMouse.inf b/Demos/Device/ClassDriver/VirtualSerialMouse/LUFA CDCMouse.inf deleted file mode 100644 index f15c93c2f..000000000 --- a/Demos/Device/ClassDriver/VirtualSerialMouse/LUFA CDCMouse.inf +++ /dev/null @@ -1,106 +0,0 @@ -;************************************************************ -; Windows USB CDC ACM Setup File -; Copyright (c) 2000 Microsoft Corporation - - -[Version] -Signature="$Windows NT$" -Class=Ports -ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} -Provider=%MFGNAME% -LayoutFile=layout.inf -CatalogFile=%MFGFILENAME%.cat -DriverVer=11/15/2007,5.1.2600.0 - -[Manufacturer] -%MFGNAME%=DeviceList, NTamd64 - -[DestinationDirs] -DefaultDestDir=12 - - -;------------------------------------------------------------------------------ -; Windows 2000/XP/Vista-32bit Sections -;------------------------------------------------------------------------------ - -[DriverInstall.nt] -include=mdmcpq.inf -CopyFiles=DriverCopyFiles.nt -AddReg=DriverInstall.nt.AddReg - -[DriverCopyFiles.nt] -usbser.sys,,,0x20 - -[DriverInstall.nt.AddReg] -HKR,,DevLoader,,*ntkern -HKR,,NTMPDriver,,%DRIVERFILENAME%.sys -HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" - -[DriverInstall.nt.Services] -AddService=usbser, 0x00000002, DriverService.nt - -[DriverService.nt] -DisplayName=%SERVICE% -ServiceType=1 -StartType=3 -ErrorControl=1 -ServiceBinary=%12%\%DRIVERFILENAME%.sys - -;------------------------------------------------------------------------------ -; Vista-64bit Sections -;------------------------------------------------------------------------------ - -[DriverInstall.NTamd64] -include=mdmcpq.inf -CopyFiles=DriverCopyFiles.NTamd64 -AddReg=DriverInstall.NTamd64.AddReg - -[DriverCopyFiles.NTamd64] -%DRIVERFILENAME%.sys,,,0x20 - -[DriverInstall.NTamd64.AddReg] -HKR,,DevLoader,,*ntkern -HKR,,NTMPDriver,,%DRIVERFILENAME%.sys -HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" - -[DriverInstall.NTamd64.Services] -AddService=usbser, 0x00000002, DriverService.NTamd64 - -[DriverService.NTamd64] -DisplayName=%SERVICE% -ServiceType=1 -StartType=3 -ErrorControl=1 -ServiceBinary=%12%\%DRIVERFILENAME%.sys - - -;------------------------------------------------------------------------------ -; Vendor and Product ID Definitions -;------------------------------------------------------------------------------ -; When developing your USB device, the VID and PID used in the PC side -; application program and the firmware on the microcontroller must match. -; Modify the below line to use your VID and PID. Use the format as shown below. -; Note: One INF file can be used for multiple devices with different VID and PIDs. -; For each supported device, append ",USB\VID_xxxx&PID_yyyy" to the end of the line. -;------------------------------------------------------------------------------ -[SourceDisksFiles] -[SourceDisksNames] -[DeviceList] -%DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_2062&MI_00 - -[DeviceList.NTamd64] -%DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_2062&MI_00 - - -;------------------------------------------------------------------------------ -; String Definitions -;------------------------------------------------------------------------------ -;Modify these strings to customize your device -;------------------------------------------------------------------------------ -[Strings] -MFGFILENAME="CDC_vista" -DRIVERFILENAME ="usbser" -MFGNAME="CCS, Inc." -INSTDISK="LUFA CDC/Mouse Driver Installer" -DESCRIPTION="Communications Port" -SERVICE="USB RS-232 Emulation Driver" \ No newline at end of file diff --git a/Demos/Device/ClassDriver/VirtualSerialMouse/LUFA VirtualSerialMouse.inf b/Demos/Device/ClassDriver/VirtualSerialMouse/LUFA VirtualSerialMouse.inf new file mode 100644 index 000000000..f15c93c2f --- /dev/null +++ b/Demos/Device/ClassDriver/VirtualSerialMouse/LUFA VirtualSerialMouse.inf @@ -0,0 +1,106 @@ +;************************************************************ +; Windows USB CDC ACM Setup File +; Copyright (c) 2000 Microsoft Corporation + + +[Version] +Signature="$Windows NT$" +Class=Ports +ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} +Provider=%MFGNAME% +LayoutFile=layout.inf +CatalogFile=%MFGFILENAME%.cat +DriverVer=11/15/2007,5.1.2600.0 + +[Manufacturer] +%MFGNAME%=DeviceList, NTamd64 + +[DestinationDirs] +DefaultDestDir=12 + + +;------------------------------------------------------------------------------ +; Windows 2000/XP/Vista-32bit Sections +;------------------------------------------------------------------------------ + +[DriverInstall.nt] +include=mdmcpq.inf +CopyFiles=DriverCopyFiles.nt +AddReg=DriverInstall.nt.AddReg + +[DriverCopyFiles.nt] +usbser.sys,,,0x20 + +[DriverInstall.nt.AddReg] +HKR,,DevLoader,,*ntkern +HKR,,NTMPDriver,,%DRIVERFILENAME%.sys +HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" + +[DriverInstall.nt.Services] +AddService=usbser, 0x00000002, DriverService.nt + +[DriverService.nt] +DisplayName=%SERVICE% +ServiceType=1 +StartType=3 +ErrorControl=1 +ServiceBinary=%12%\%DRIVERFILENAME%.sys + +;------------------------------------------------------------------------------ +; Vista-64bit Sections +;------------------------------------------------------------------------------ + +[DriverInstall.NTamd64] +include=mdmcpq.inf +CopyFiles=DriverCopyFiles.NTamd64 +AddReg=DriverInstall.NTamd64.AddReg + +[DriverCopyFiles.NTamd64] +%DRIVERFILENAME%.sys,,,0x20 + +[DriverInstall.NTamd64.AddReg] +HKR,,DevLoader,,*ntkern +HKR,,NTMPDriver,,%DRIVERFILENAME%.sys +HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" + +[DriverInstall.NTamd64.Services] +AddService=usbser, 0x00000002, DriverService.NTamd64 + +[DriverService.NTamd64] +DisplayName=%SERVICE% +ServiceType=1 +StartType=3 +ErrorControl=1 +ServiceBinary=%12%\%DRIVERFILENAME%.sys + + +;------------------------------------------------------------------------------ +; Vendor and Product ID Definitions +;------------------------------------------------------------------------------ +; When developing your USB device, the VID and PID used in the PC side +; application program and the firmware on the microcontroller must match. +; Modify the below line to use your VID and PID. Use the format as shown below. +; Note: One INF file can be used for multiple devices with different VID and PIDs. +; For each supported device, append ",USB\VID_xxxx&PID_yyyy" to the end of the line. +;------------------------------------------------------------------------------ +[SourceDisksFiles] +[SourceDisksNames] +[DeviceList] +%DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_2062&MI_00 + +[DeviceList.NTamd64] +%DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_2062&MI_00 + + +;------------------------------------------------------------------------------ +; String Definitions +;------------------------------------------------------------------------------ +;Modify these strings to customize your device +;------------------------------------------------------------------------------ +[Strings] +MFGFILENAME="CDC_vista" +DRIVERFILENAME ="usbser" +MFGNAME="CCS, Inc." +INSTDISK="LUFA CDC/Mouse Driver Installer" +DESCRIPTION="Communications Port" +SERVICE="USB RS-232 Emulation Driver" \ No newline at end of file diff --git a/Demos/Device/ClassDriver/VirtualSerialMouse/VirtualSerialMouse.c b/Demos/Device/ClassDriver/VirtualSerialMouse/VirtualSerialMouse.c new file mode 100644 index 000000000..d979e665c --- /dev/null +++ b/Demos/Device/ClassDriver/VirtualSerialMouse/VirtualSerialMouse.c @@ -0,0 +1,240 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2009. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, and distribute this software + and its documentation for any purpose and without fee is hereby + granted, provided that the above copyright notice appear in all + copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * + * Main source file for the CDCMouse demo. This file contains the main tasks of + * the demo and is responsible for the initial application hardware configuration. + */ + +#include "CDCMouse.h" + +/** LUFA CDC Class driver interface configuration and state information. This structure is + * passed to all CDC Class driver functions, so that multiple instances of the same class + * within a device can be differentiated from one another. + */ +USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface = + { + .Config = + { + .ControlInterfaceNumber = 0, + + .DataINEndpointNumber = CDC_TX_EPNUM, + .DataINEndpointSize = CDC_TXRX_EPSIZE, + .DataINEndpointDoubleBank = false, + + .DataOUTEndpointNumber = CDC_RX_EPNUM, + .DataOUTEndpointSize = CDC_TXRX_EPSIZE, + .DataOUTEndpointDoubleBank = false, + + .NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM, + .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE, + .NotificationEndpointDoubleBank = false, + }, + }; + +/** Buffer to hold the previously generated Mouse HID report, for comparison purposes inside the HID class driver. */ +uint8_t PrevMouseHIDReportBuffer[sizeof(USB_MouseReport_Data_t)]; + +/** LUFA HID Class driver interface configuration and state information. This structure is + * passed to all HID Class driver functions, so that multiple instances of the same class + * within a device can be differentiated from one another. + */ +USB_ClassInfo_HID_Device_t Mouse_HID_Interface = + { + .Config = + { + .InterfaceNumber = 0, + + .ReportINEndpointNumber = MOUSE_EPNUM, + .ReportINEndpointSize = MOUSE_EPSIZE, + .ReportINEndpointDoubleBank = false, + + .PrevReportINBuffer = PrevMouseHIDReportBuffer, + .PrevReportINBufferSize = sizeof(PrevMouseHIDReportBuffer), + }, + }; + +/** Main program entry point. This routine contains the overall program flow, including initial + * setup of all components and the main program loop. + */ +int main(void) +{ + SetupHardware(); + + LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); + + for (;;) + { + CheckJoystickMovement(); + + /* Must throw away unused bytes from the host, or it will lock up while waiting for the device */ + while (CDC_Device_BytesReceived(&VirtualSerial_CDC_Interface)) + CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface); + + CDC_Device_USBTask(&VirtualSerial_CDC_Interface); + HID_Device_USBTask(&Mouse_HID_Interface); + USB_USBTask(); + } +} + +/** Configures the board hardware and chip peripherals for the demo's functionality. */ +void SetupHardware(void) +{ + /* Disable watchdog if enabled by bootloader/fuses */ + MCUSR &= ~(1 << WDRF); + wdt_disable(); + + /* Disable clock division */ + clock_prescale_set(clock_div_1); + + /* Hardware Initialization */ + Joystick_Init(); + LEDs_Init(); + USB_Init(); +} + +/** Checks for changes in the position of the board joystick, sending strings to the host upon each change. */ +void CheckJoystickMovement(void) +{ + uint8_t JoyStatus_LCL = Joystick_GetStatus(); + char* ReportString = NULL; + static bool ActionSent = false; + + if (JoyStatus_LCL & JOY_UP) + ReportString = "Joystick Up\r\n"; + else if (JoyStatus_LCL & JOY_DOWN) + ReportString = "Joystick Down\r\n"; + else if (JoyStatus_LCL & JOY_LEFT) + ReportString = "Joystick Left\r\n"; + else if (JoyStatus_LCL & JOY_RIGHT) + ReportString = "Joystick Right\r\n"; + else if (JoyStatus_LCL & JOY_PRESS) + ReportString = "Joystick Pressed\r\n"; + else + ActionSent = false; + + if ((ReportString != NULL) && (ActionSent == false)) + { + ActionSent = true; + + CDC_Device_SendString(&VirtualSerial_CDC_Interface, ReportString, strlen(ReportString)); + } +} + +/** Event handler for the library USB Connection event. */ +void EVENT_USB_Device_Connect(void) +{ + LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); +} + +/** Event handler for the library USB Disconnection event. */ +void EVENT_USB_Device_Disconnect(void) +{ + LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); +} + +/** Event handler for the library USB Configuration Changed event. */ +void EVENT_USB_Device_ConfigurationChanged(void) +{ + LEDs_SetAllLEDs(LEDMASK_USB_READY); + + if (!(CDC_Device_ConfigureEndpoints(&VirtualSerial_CDC_Interface))) + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); + + if (!(HID_Device_ConfigureEndpoints(&Mouse_HID_Interface))) + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); + + USB_Device_EnableSOFEvents(); +} + +/** Event handler for the library USB Unhandled Control Request event. */ +void EVENT_USB_Device_UnhandledControlRequest(void) +{ + CDC_Device_ProcessControlRequest(&VirtualSerial_CDC_Interface); + HID_Device_ProcessControlRequest(&Mouse_HID_Interface); +} + +/** Event handler for the USB device Start Of Frame event. */ +void EVENT_USB_Device_StartOfFrame(void) +{ + HID_Device_MillisecondElapsed(&Mouse_HID_Interface); +} + +/** HID class driver callback function for the creation of HID reports to the host. + * + * \param[in] HIDInterfaceInfo Pointer to the HID class interface configuration structure being referenced + * \param[in,out] ReportID Report ID requested by the host if non-zero, otherwise callback should set to the generated report ID + * \param[in] ReportType Type of the report to create, either REPORT_ITEM_TYPE_In or REPORT_ITEM_TYPE_Feature + * \param[out] ReportData Pointer to a buffer where the created report should be stored + * \param[out] ReportSize Number of bytes written in the report (or zero if no report is to be sent + * + * \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent + */ +bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID, + const uint8_t ReportType, void* ReportData, uint16_t* ReportSize) +{ + USB_MouseReport_Data_t* MouseReport = (USB_MouseReport_Data_t*)ReportData; + + uint8_t JoyStatus_LCL = Joystick_GetStatus(); + uint8_t ButtonStatus_LCL = Buttons_GetStatus(); + + if (JoyStatus_LCL & JOY_UP) + MouseReport->Y = -1; + else if (JoyStatus_LCL & JOY_DOWN) + MouseReport->Y = 1; + + if (JoyStatus_LCL & JOY_LEFT) + MouseReport->X = -1; + else if (JoyStatus_LCL & JOY_RIGHT) + MouseReport->X = 1; + + if (JoyStatus_LCL & JOY_PRESS) + MouseReport->Button = (1 << 0); + + if (ButtonStatus_LCL & BUTTONS_BUTTON1) + MouseReport->Button |= (1 << 1); + + *ReportSize = sizeof(USB_MouseReport_Data_t); + return true; +} + +/** HID class driver callback function for the processing of HID reports from the host. + * + * \param[in] HIDInterfaceInfo Pointer to the HID class interface configuration structure being referenced + * \param[in] ReportID Report ID of the received report from the host + * \param[in] ReportData Pointer to a buffer where the created report has been stored + * \param[in] ReportSize Size in bytes of the received HID report + */ +void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, const uint8_t ReportID, + const void* ReportData, const uint16_t ReportSize) +{ + // Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports +} diff --git a/Demos/Device/ClassDriver/VirtualSerialMouse/VirtualSerialMouse.h b/Demos/Device/ClassDriver/VirtualSerialMouse/VirtualSerialMouse.h new file mode 100644 index 000000000..bee1b0435 --- /dev/null +++ b/Demos/Device/ClassDriver/VirtualSerialMouse/VirtualSerialMouse.h @@ -0,0 +1,82 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2009. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, and distribute this software + and its documentation for any purpose and without fee is hereby + granted, provided that the above copyright notice appear in all + copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * + * Header file for CDCMouse.c. + */ + +#ifndef _CDC_MOUSE_H_ +#define _CDC_MOUSE_H_ + + /* Includes: */ + #include + #include + #include + #include + + #include "Descriptors.h" + + #include + #include + #include + #include + #include + #include + #include + + /* Macros: */ + /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ + #define LEDMASK_USB_NOTREADY LEDS_LED1 + + /** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */ + #define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3) + + /** LED mask for the library LED driver, to indicate that the USB interface is ready. */ + #define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4) + + /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ + #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) + + /* Function Prototypes: */ + void SetupHardware(void); + void CheckJoystickMovement(void); + + void EVENT_USB_Device_Connect(void); + void EVENT_USB_Device_Disconnect(void); + void EVENT_USB_Device_ConfigurationChanged(void); + void EVENT_USB_Device_UnhandledControlRequest(void); + void EVENT_USB_Device_StartOfFrame(void); + + bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID, + const uint8_t ReportType, void* ReportData, uint16_t* ReportSize); + void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, const uint8_t ReportID, + const void* ReportData, const uint16_t ReportSize); +#endif diff --git a/Demos/Device/ClassDriver/VirtualSerialMouse/VirtualSerialMouse.txt b/Demos/Device/ClassDriver/VirtualSerialMouse/VirtualSerialMouse.txt new file mode 100644 index 000000000..ff0d8a361 --- /dev/null +++ b/Demos/Device/ClassDriver/VirtualSerialMouse/VirtualSerialMouse.txt @@ -0,0 +1,75 @@ +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** \mainpage Combined Communications Device Class (Virtual Serial Port) and Mouse Demo + * + * \section SSec_Compat Demo Compatibility: + * + * The following list indicates what microcontrollers are compatible with this demo. + * + * - Series 7 USB AVRs + * - Series 6 USB AVRs + * - Series 4 USB AVRs + * - Series 2 USB AVRs + * + * \section SSec_Info USB Information: + * + * The following table gives a rundown of the USB utilization of this demo. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
USB Mode:Device
USB Class:Communications Device Class (CDC)Human Interface Device Class (HID)
USB Subclass:Abstract Control Model (ACM)Mouse Subclass
Relevant Standards:USBIF CDC Class StandardUSBIF HID Specification, USBIF HID Usage Tables
Usable Speeds:Full Speed Mode
+ * + * \section SSec_Description Project Description: + * + * Combined Communications Device Class/Mouse demonstration application. + * This gives a simple reference application for implementing a combined + * CDC and HID device acting as a both a virtual serial port and a mouse. + * Joystick actions are transmitted to the host as strings and as mouse + * movements. The device does not respond to serial data sent from the host. + * + * After running this demo for the first time on a new computer, + * you will need to supply the .INF file located in this demo + * project's directory as the device's driver when running under + * Windows. This will enable Windows to use its inbuilt CDC drivers, + * negating the need for custom drivers for the device. Other + * Operating Systems should automatically use their own inbuilt + * CDC-ACM drivers. + * + * \section SSec_Options Project Options + * + * The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. + * + * + * + * + * + *
+ * None + *
+ */ \ No newline at end of file diff --git a/Demos/Device/ClassDriver/VirtualSerialMouse/makefile b/Demos/Device/ClassDriver/VirtualSerialMouse/makefile index 85e3e97a3..990760e85 100644 --- a/Demos/Device/ClassDriver/VirtualSerialMouse/makefile +++ b/Demos/Device/ClassDriver/VirtualSerialMouse/makefile @@ -102,7 +102,7 @@ FORMAT = ihex # Target file name (without extension). -TARGET = CDCMouse +TARGET = VirtualSerialMouse # Object files directory -- cgit v1.2.3