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. --- Demos/Host/LowLevel/VirtualSerialHost/CDCHost.c | 268 --------------------- Demos/Host/LowLevel/VirtualSerialHost/CDCHost.h | 86 ------- Demos/Host/LowLevel/VirtualSerialHost/CDCHost.txt | 65 ----- Demos/Host/LowLevel/VirtualSerialHost/Doxygen.conf | 2 +- .../LowLevel/VirtualSerialHost/VirtualSerialHost.c | 268 +++++++++++++++++++++ .../LowLevel/VirtualSerialHost/VirtualSerialHost.h | 86 +++++++ .../VirtualSerialHost/VirtualSerialHost.txt | 65 +++++ Demos/Host/LowLevel/VirtualSerialHost/makefile | 2 +- Demos/Host/LowLevel/makefile | 8 +- 9 files changed, 425 insertions(+), 425 deletions(-) delete mode 100644 Demos/Host/LowLevel/VirtualSerialHost/CDCHost.c delete mode 100644 Demos/Host/LowLevel/VirtualSerialHost/CDCHost.h delete mode 100644 Demos/Host/LowLevel/VirtualSerialHost/CDCHost.txt create mode 100644 Demos/Host/LowLevel/VirtualSerialHost/VirtualSerialHost.c create mode 100644 Demos/Host/LowLevel/VirtualSerialHost/VirtualSerialHost.h create mode 100644 Demos/Host/LowLevel/VirtualSerialHost/VirtualSerialHost.txt (limited to 'Demos/Host/LowLevel') diff --git a/Demos/Host/LowLevel/VirtualSerialHost/CDCHost.c b/Demos/Host/LowLevel/VirtualSerialHost/CDCHost.c deleted file mode 100644 index c4322587e..000000000 --- a/Demos/Host/LowLevel/VirtualSerialHost/CDCHost.c +++ /dev/null @@ -1,268 +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 CDCHost demo. This file contains the main tasks of - * the demo and is responsible for the initial application hardware configuration. - */ - -#include "CDCHost.h" - -#if 0 -/* NOTE: Here you can set up a standard stream using the created virtual serial port, so that the standard stream functions in - * can be used on the virtual serial port (e.g. fprintf(&USBSerial, "Test"); to print a string). - */ - -static int CDC_putchar(char c, FILE *stream) -{ - Pipe_SelectPipe(CDC_DATAPIPE_OUT); - - if (Pipe_WaitUntilReady()) - return -1; - - Pipe_Write_Byte(c); - Pipe_ClearIN(); - - return 0; -} - -static int CDC_getchar(FILE *stream) -{ - int c; - - Pipe_SelectPipe(CDC_DATAPIPE_IN); - - for (;;) - { - if (Pipe_WaitUntilReady()) - return -1; - - if (!(Pipe_BytesInPipe())) - { - Pipe_ClearOUT(); - } - else - { - c = Pipe_Read_Byte(); - break; - } - } - - return c; -} - -static FILE USBSerial = FDEV_SETUP_STREAM(CDC_putchar, CDC_getchar, _FDEV_SETUP_RW); -#endif - -/** Main program entry point. This routine configures the hardware required by the application, then - * enters a loop to run the application tasks in sequence. - */ -int main(void) -{ - SetupHardware(); - - puts_P(PSTR(ESC_FG_CYAN "CDC Host Demo running.\r\n" ESC_FG_WHITE)); - - LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); - - for (;;) - { - CDC_Host_Task(); - 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 */ - SerialStream_Init(9600, false); - LEDs_Init(); - USB_Init(); -} - -/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and - * starts the library USB task to begin the enumeration and USB management process. - */ -void EVENT_USB_Host_DeviceAttached(void) -{ - puts_P(PSTR(ESC_FG_GREEN "Device Attached.\r\n" ESC_FG_WHITE)); - LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); -} - -/** Event handler for the USB_DeviceUnattached event. This indicates that a device has been removed from the host, and - * stops the library USB task management process. - */ -void EVENT_USB_Host_DeviceUnattached(void) -{ - puts_P(PSTR(ESC_FG_GREEN "\r\nDevice Unattached.\r\n" ESC_FG_WHITE)); - LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); -} - -/** Event handler for the USB_DeviceEnumerationComplete event. This indicates that a device has been successfully - * enumerated by the host and is now ready to be used by the application. - */ -void EVENT_USB_Host_DeviceEnumerationComplete(void) -{ - LEDs_SetAllLEDs(LEDMASK_USB_READY); -} - -/** Event handler for the USB_HostError event. This indicates that a hardware error occurred while in host mode. */ -void EVENT_USB_Host_HostError(const uint8_t ErrorCode) -{ - USB_ShutDown(); - - printf_P(PSTR(ESC_FG_RED "Host Mode Error\r\n" - " -- Error Code %d\r\n" ESC_FG_WHITE), ErrorCode); - - LEDs_SetAllLEDs(LEDMASK_USB_ERROR); - for(;;); -} - -/** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while - * enumerating an attached USB device. - */ -void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode) -{ - printf_P(PSTR(ESC_FG_RED "Dev Enum Error\r\n" - " -- Error Code %d\r\n" - " -- Sub Error Code %d\r\n" - " -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState); - - LEDs_SetAllLEDs(LEDMASK_USB_ERROR); -} - -/** Task to set the configuration of the attached device after it has been enumerated, and to read in - * data received from the attached CDC device and print it to the serial port. - */ -void CDC_Host_Task(void) -{ - uint8_t ErrorCode; - - switch (USB_HostState) - { - case HOST_STATE_Addressed: - puts_P(PSTR("Getting Config Data.\r\n")); - - /* Get and process the configuration descriptor data */ - if ((ErrorCode = ProcessConfigurationDescriptor()) != SuccessfulConfigRead) - { - if (ErrorCode == ControlError) - puts_P(PSTR(ESC_FG_RED "Control Error (Get Configuration).\r\n")); - else - puts_P(PSTR(ESC_FG_RED "Invalid Device.\r\n")); - - printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode); - - /* Indicate error via status LEDs */ - LEDs_SetAllLEDs(LEDMASK_USB_ERROR); - - /* Wait until USB device disconnected */ - USB_HostState = HOST_STATE_WaitForDeviceRemoval; - break; - } - - /* Set the device configuration to the first configuration (rarely do devices use multiple configurations) */ - if ((ErrorCode = USB_Host_SetDeviceConfiguration(1)) != HOST_SENDCONTROL_Successful) - { - printf_P(PSTR(ESC_FG_RED "Control Error (Set Configuration).\r\n" - " -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode); - - /* Indicate error via status LEDs */ - LEDs_SetAllLEDs(LEDMASK_USB_ERROR); - - /* Wait until USB device disconnected */ - USB_HostState = HOST_STATE_WaitForDeviceRemoval; - break; - } - - puts_P(PSTR("CDC Device Enumerated.\r\n")); - - USB_HostState = HOST_STATE_Configured; - break; - case HOST_STATE_Configured: - /* Select the data IN pipe */ - Pipe_SelectPipe(CDC_DATAPIPE_IN); - Pipe_SetPipeToken(PIPE_TOKEN_IN); - Pipe_Unfreeze(); - - /* Check to see if a packet has been received */ - if (Pipe_IsINReceived()) - { - /* Re-freeze IN pipe after the packet has been received */ - Pipe_Freeze(); - - /* Check if data is in the pipe */ - if (Pipe_IsReadWriteAllowed()) - { - /* Get the length of the pipe data, and create a new buffer to hold it */ - uint16_t BufferLength = Pipe_BytesInPipe(); - uint8_t Buffer[BufferLength]; - - /* Read in the pipe data to the temporary buffer */ - Pipe_Read_Stream_LE(Buffer, BufferLength); - - /* Print out the buffer contents to the USART */ - for (uint16_t BufferByte = 0; BufferByte < BufferLength; BufferByte++) - putchar(Buffer[BufferByte]); - } - - /* Clear the pipe after it is read, ready for the next packet */ - Pipe_ClearIN(); - } - - /* Re-freeze IN pipe after use */ - Pipe_Freeze(); - - /* Select and unfreeze the notification pipe */ - Pipe_SelectPipe(CDC_NOTIFICATIONPIPE); - Pipe_Unfreeze(); - - /* Check if a packet has been received */ - if (Pipe_IsINReceived()) - { - /* Discard the unused event notification */ - Pipe_ClearIN(); - } - - /* Freeze notification IN pipe after use */ - Pipe_Freeze(); - - break; - } -} diff --git a/Demos/Host/LowLevel/VirtualSerialHost/CDCHost.h b/Demos/Host/LowLevel/VirtualSerialHost/CDCHost.h deleted file mode 100644 index b6d3a3cd4..000000000 --- a/Demos/Host/LowLevel/VirtualSerialHost/CDCHost.h +++ /dev/null @@ -1,86 +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 CDCHost.c. - */ - -#ifndef _CDC_HOST_H_ -#define _CDC_HOST_H_ - - /* Includes: */ - #include - #include - #include - #include - #include - - #include - #include - #include - #include - #include - - #include "ConfigDescriptor.h" - - /* Macros: */ - /** Pipe number for the CDC data IN pipe */ - #define CDC_DATAPIPE_IN 1 - - /** Pipe number for the CDC data OUT pipe */ - #define CDC_DATAPIPE_OUT 2 - - /** Pipe number for the CDC notification pipe */ - #define CDC_NOTIFICATIONPIPE 3 - - /** 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 CDC_Host_Task(void); - - void EVENT_USB_Host_HostError(const uint8_t ErrorCode); - void EVENT_USB_Host_DeviceAttached(void); - void EVENT_USB_Host_DeviceUnattached(void); - void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode); - void EVENT_USB_Host_DeviceEnumerationComplete(void); - -#endif diff --git a/Demos/Host/LowLevel/VirtualSerialHost/CDCHost.txt b/Demos/Host/LowLevel/VirtualSerialHost/CDCHost.txt deleted file mode 100644 index 65999926c..000000000 --- a/Demos/Host/LowLevel/VirtualSerialHost/CDCHost.txt +++ /dev/null @@ -1,65 +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 CDC Host Demo - * - * \section SSec_Compat Demo Compatibility: - * - * The following list indicates what microcontrollers are compatible with this demo. - * - * - Series 7 USB AVRs - * - * \section SSec_Info USB Information: - * - * The following table gives a rundown of the USB utilization of this demo. - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
USB Mode:Host
USB Class:Communications Device Class (CDC)
USB Subclass:Abstract Control Model (ACM)
Relevant Standards:USBIF CDC Class Standard
Usable Speeds:Full Speed Mode
- * - * \section SSec_Description Project Description: - * - * CDC host demonstration application. This gives a simple reference application - * for implementing a USB CDC host, for CDC devices using the standard ACM profile. - * - * This demo prints out received CDC data through the serial port. - * - * Not that this demo is only compatible with devices which report the correct CDC - * and ACM class, subclass and protocol values. Most USB-Serial cables have vendor - * specific features, thus use vendor-specific class/subclass/protocol codes to force - * the user to use specialized drivers. This demo is not compatible with such devices. - * - * \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 - *
- */ diff --git a/Demos/Host/LowLevel/VirtualSerialHost/Doxygen.conf b/Demos/Host/LowLevel/VirtualSerialHost/Doxygen.conf index 3f2e0b920..097bd05cc 100644 --- a/Demos/Host/LowLevel/VirtualSerialHost/Doxygen.conf +++ b/Demos/Host/LowLevel/VirtualSerialHost/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 - CDC Host Demo" +PROJECT_NAME = "LUFA Library - Virtual Serial Host 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/Host/LowLevel/VirtualSerialHost/VirtualSerialHost.c b/Demos/Host/LowLevel/VirtualSerialHost/VirtualSerialHost.c new file mode 100644 index 000000000..c4322587e --- /dev/null +++ b/Demos/Host/LowLevel/VirtualSerialHost/VirtualSerialHost.c @@ -0,0 +1,268 @@ +/* + 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 CDCHost demo. This file contains the main tasks of + * the demo and is responsible for the initial application hardware configuration. + */ + +#include "CDCHost.h" + +#if 0 +/* NOTE: Here you can set up a standard stream using the created virtual serial port, so that the standard stream functions in + * can be used on the virtual serial port (e.g. fprintf(&USBSerial, "Test"); to print a string). + */ + +static int CDC_putchar(char c, FILE *stream) +{ + Pipe_SelectPipe(CDC_DATAPIPE_OUT); + + if (Pipe_WaitUntilReady()) + return -1; + + Pipe_Write_Byte(c); + Pipe_ClearIN(); + + return 0; +} + +static int CDC_getchar(FILE *stream) +{ + int c; + + Pipe_SelectPipe(CDC_DATAPIPE_IN); + + for (;;) + { + if (Pipe_WaitUntilReady()) + return -1; + + if (!(Pipe_BytesInPipe())) + { + Pipe_ClearOUT(); + } + else + { + c = Pipe_Read_Byte(); + break; + } + } + + return c; +} + +static FILE USBSerial = FDEV_SETUP_STREAM(CDC_putchar, CDC_getchar, _FDEV_SETUP_RW); +#endif + +/** Main program entry point. This routine configures the hardware required by the application, then + * enters a loop to run the application tasks in sequence. + */ +int main(void) +{ + SetupHardware(); + + puts_P(PSTR(ESC_FG_CYAN "CDC Host Demo running.\r\n" ESC_FG_WHITE)); + + LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); + + for (;;) + { + CDC_Host_Task(); + 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 */ + SerialStream_Init(9600, false); + LEDs_Init(); + USB_Init(); +} + +/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and + * starts the library USB task to begin the enumeration and USB management process. + */ +void EVENT_USB_Host_DeviceAttached(void) +{ + puts_P(PSTR(ESC_FG_GREEN "Device Attached.\r\n" ESC_FG_WHITE)); + LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); +} + +/** Event handler for the USB_DeviceUnattached event. This indicates that a device has been removed from the host, and + * stops the library USB task management process. + */ +void EVENT_USB_Host_DeviceUnattached(void) +{ + puts_P(PSTR(ESC_FG_GREEN "\r\nDevice Unattached.\r\n" ESC_FG_WHITE)); + LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); +} + +/** Event handler for the USB_DeviceEnumerationComplete event. This indicates that a device has been successfully + * enumerated by the host and is now ready to be used by the application. + */ +void EVENT_USB_Host_DeviceEnumerationComplete(void) +{ + LEDs_SetAllLEDs(LEDMASK_USB_READY); +} + +/** Event handler for the USB_HostError event. This indicates that a hardware error occurred while in host mode. */ +void EVENT_USB_Host_HostError(const uint8_t ErrorCode) +{ + USB_ShutDown(); + + printf_P(PSTR(ESC_FG_RED "Host Mode Error\r\n" + " -- Error Code %d\r\n" ESC_FG_WHITE), ErrorCode); + + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); + for(;;); +} + +/** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while + * enumerating an attached USB device. + */ +void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode) +{ + printf_P(PSTR(ESC_FG_RED "Dev Enum Error\r\n" + " -- Error Code %d\r\n" + " -- Sub Error Code %d\r\n" + " -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState); + + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); +} + +/** Task to set the configuration of the attached device after it has been enumerated, and to read in + * data received from the attached CDC device and print it to the serial port. + */ +void CDC_Host_Task(void) +{ + uint8_t ErrorCode; + + switch (USB_HostState) + { + case HOST_STATE_Addressed: + puts_P(PSTR("Getting Config Data.\r\n")); + + /* Get and process the configuration descriptor data */ + if ((ErrorCode = ProcessConfigurationDescriptor()) != SuccessfulConfigRead) + { + if (ErrorCode == ControlError) + puts_P(PSTR(ESC_FG_RED "Control Error (Get Configuration).\r\n")); + else + puts_P(PSTR(ESC_FG_RED "Invalid Device.\r\n")); + + printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode); + + /* Indicate error via status LEDs */ + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); + + /* Wait until USB device disconnected */ + USB_HostState = HOST_STATE_WaitForDeviceRemoval; + break; + } + + /* Set the device configuration to the first configuration (rarely do devices use multiple configurations) */ + if ((ErrorCode = USB_Host_SetDeviceConfiguration(1)) != HOST_SENDCONTROL_Successful) + { + printf_P(PSTR(ESC_FG_RED "Control Error (Set Configuration).\r\n" + " -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode); + + /* Indicate error via status LEDs */ + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); + + /* Wait until USB device disconnected */ + USB_HostState = HOST_STATE_WaitForDeviceRemoval; + break; + } + + puts_P(PSTR("CDC Device Enumerated.\r\n")); + + USB_HostState = HOST_STATE_Configured; + break; + case HOST_STATE_Configured: + /* Select the data IN pipe */ + Pipe_SelectPipe(CDC_DATAPIPE_IN); + Pipe_SetPipeToken(PIPE_TOKEN_IN); + Pipe_Unfreeze(); + + /* Check to see if a packet has been received */ + if (Pipe_IsINReceived()) + { + /* Re-freeze IN pipe after the packet has been received */ + Pipe_Freeze(); + + /* Check if data is in the pipe */ + if (Pipe_IsReadWriteAllowed()) + { + /* Get the length of the pipe data, and create a new buffer to hold it */ + uint16_t BufferLength = Pipe_BytesInPipe(); + uint8_t Buffer[BufferLength]; + + /* Read in the pipe data to the temporary buffer */ + Pipe_Read_Stream_LE(Buffer, BufferLength); + + /* Print out the buffer contents to the USART */ + for (uint16_t BufferByte = 0; BufferByte < BufferLength; BufferByte++) + putchar(Buffer[BufferByte]); + } + + /* Clear the pipe after it is read, ready for the next packet */ + Pipe_ClearIN(); + } + + /* Re-freeze IN pipe after use */ + Pipe_Freeze(); + + /* Select and unfreeze the notification pipe */ + Pipe_SelectPipe(CDC_NOTIFICATIONPIPE); + Pipe_Unfreeze(); + + /* Check if a packet has been received */ + if (Pipe_IsINReceived()) + { + /* Discard the unused event notification */ + Pipe_ClearIN(); + } + + /* Freeze notification IN pipe after use */ + Pipe_Freeze(); + + break; + } +} diff --git a/Demos/Host/LowLevel/VirtualSerialHost/VirtualSerialHost.h b/Demos/Host/LowLevel/VirtualSerialHost/VirtualSerialHost.h new file mode 100644 index 000000000..b6d3a3cd4 --- /dev/null +++ b/Demos/Host/LowLevel/VirtualSerialHost/VirtualSerialHost.h @@ -0,0 +1,86 @@ +/* + 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 CDCHost.c. + */ + +#ifndef _CDC_HOST_H_ +#define _CDC_HOST_H_ + + /* Includes: */ + #include + #include + #include + #include + #include + + #include + #include + #include + #include + #include + + #include "ConfigDescriptor.h" + + /* Macros: */ + /** Pipe number for the CDC data IN pipe */ + #define CDC_DATAPIPE_IN 1 + + /** Pipe number for the CDC data OUT pipe */ + #define CDC_DATAPIPE_OUT 2 + + /** Pipe number for the CDC notification pipe */ + #define CDC_NOTIFICATIONPIPE 3 + + /** 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 CDC_Host_Task(void); + + void EVENT_USB_Host_HostError(const uint8_t ErrorCode); + void EVENT_USB_Host_DeviceAttached(void); + void EVENT_USB_Host_DeviceUnattached(void); + void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode); + void EVENT_USB_Host_DeviceEnumerationComplete(void); + +#endif diff --git a/Demos/Host/LowLevel/VirtualSerialHost/VirtualSerialHost.txt b/Demos/Host/LowLevel/VirtualSerialHost/VirtualSerialHost.txt new file mode 100644 index 000000000..65999926c --- /dev/null +++ b/Demos/Host/LowLevel/VirtualSerialHost/VirtualSerialHost.txt @@ -0,0 +1,65 @@ +/** \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 CDC Host Demo + * + * \section SSec_Compat Demo Compatibility: + * + * The following list indicates what microcontrollers are compatible with this demo. + * + * - Series 7 USB AVRs + * + * \section SSec_Info USB Information: + * + * The following table gives a rundown of the USB utilization of this demo. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
USB Mode:Host
USB Class:Communications Device Class (CDC)
USB Subclass:Abstract Control Model (ACM)
Relevant Standards:USBIF CDC Class Standard
Usable Speeds:Full Speed Mode
+ * + * \section SSec_Description Project Description: + * + * CDC host demonstration application. This gives a simple reference application + * for implementing a USB CDC host, for CDC devices using the standard ACM profile. + * + * This demo prints out received CDC data through the serial port. + * + * Not that this demo is only compatible with devices which report the correct CDC + * and ACM class, subclass and protocol values. Most USB-Serial cables have vendor + * specific features, thus use vendor-specific class/subclass/protocol codes to force + * the user to use specialized drivers. This demo is not compatible with such devices. + * + * \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 + *
+ */ diff --git a/Demos/Host/LowLevel/VirtualSerialHost/makefile b/Demos/Host/LowLevel/VirtualSerialHost/makefile index 6c9c7c8f8..168b1b474 100644 --- a/Demos/Host/LowLevel/VirtualSerialHost/makefile +++ b/Demos/Host/LowLevel/VirtualSerialHost/makefile @@ -102,7 +102,7 @@ FORMAT = ihex # Target file name (without extension). -TARGET = CDCHost +TARGET = VirtualSerialHost # Object files directory diff --git a/Demos/Host/LowLevel/makefile b/Demos/Host/LowLevel/makefile index a69b25ba4..e81285678 100644 --- a/Demos/Host/LowLevel/makefile +++ b/Demos/Host/LowLevel/makefile @@ -14,9 +14,6 @@ # code. all: - make -C CDCHost clean - make -C CDCHost all - make -C GenericHIDHost clean make -C GenericHIDHost all @@ -47,8 +44,10 @@ all: make -C RNDISEthernetHost clean make -C RNDISEthernetHost all + make -C VirtualSerialHost clean + make -C VirtualSerialHost all + %: - make -C CDCHost $@ make -C GenericHIDHost $@ make -C JoystickHostWithParser $@ make -C KeyboardHost $@ @@ -60,3 +59,4 @@ all: make -C PrinterHost $@ make -C StillImageHost $@ make -C RNDISEthernetHost $@ + make -C VirtualSerialHost $@ -- cgit v1.2.3